Lines Matching defs:vg

98 static int __archive(struct volume_group *vg)
102 if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
105 return archive_vg(vg, vg->cmd->archive_params->dir, desc,
106 vg->cmd->archive_params->keep_days,
107 vg->cmd->archive_params->keep_number);
110 int archive(struct volume_group *vg)
112 if (!vg->cmd->archive_params->enabled || !vg->cmd->archive_params->dir)
126 if (!dm_create_dir(vg->cmd->archive_params->dir))
130 if ((access(vg->cmd->archive_params->dir, R_OK | W_OK | X_OK) == -1) &&
134 log_verbose("Archiving volume group \"%s\" metadata (seqno %u).", vg->name,
135 vg->seqno);
136 if (!__archive(vg)) {
138 vg->name);
200 static int __backup(struct volume_group *vg)
205 if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0)))
209 vg->cmd->backup_params->dir, vg->name) < 0) {
215 return backup_to_file(name, desc, vg);
218 int backup_locally(struct volume_group *vg)
220 if (!vg->cmd->backup_params->enabled || !vg->cmd->backup_params->dir) {
236 if (!dm_create_dir(vg->cmd->backup_params->dir))
240 if ((access(vg->cmd->backup_params->dir, R_OK | W_OK | X_OK) == -1) &&
244 if (!__backup(vg)) {
246 vg->name);
253 int backup(struct volume_group *vg)
255 if (vg_is_clustered(vg))
256 remote_backup_metadata(vg);
258 return backup_locally(vg);
281 struct volume_group *vg = NULL;
295 if (!(vg = mda->ops->vg_read(tf, vg_name, mda)))
301 return vg;
305 int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
317 if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg->name,
324 dm_list_iterate_items(pvl, &vg->pvs) {
336 if (!vg->fid->fmt->ops->
337 pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, 0, 0UL,
338 UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) {
345 if (!vg_write(vg) || !vg_commit(vg))
355 struct volume_group *vg;
361 if (!(vg = backup_read_vg(cmd, vg_name, file)))
364 missing_pvs = vg_missing_pv_count(vg);
366 r = backup_restore_vg(cmd, vg);
369 "marked as missing.", vg->name, missing_pvs);
371 vg_release(vg);
388 int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
396 cmd = vg->cmd;
398 log_verbose("Creating volume group backup \"%s\" (seqno %u).", file, vg->seqno);
409 if (!(r = mda->ops->vg_write(tf, vg, mda))) {
414 !(r = mda->ops->vg_commit(tf, vg, mda))) {
426 void check_current_backup(struct volume_group *vg)
432 if (vg_is_exported(vg))
436 vg->cmd->backup_params->dir, vg->name) < 0) {
443 if ((vg_backup = backup_read_vg(vg->cmd, vg->name, path)) &&
444 (vg->seqno == vg_backup->seqno) &&
445 (id_equal(&vg->id, &vg_backup->id))) {
456 archive(vg);
457 backup_locally(vg);