1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00
lvm2/tools/vgcfgbackup.c
Alasdair Kergon 4a624ca055 o ACTIVE is no longer a status flag - lv_active() used to check if an LV
is active in the device-mapper.
o Many operations can be carried out regardless of whether the VG is
  active or not.
o vgscan does not activate anything - use vgchange.
o Change lvrename to support renaming of active LVs.
o Remove '//' appearing in some pathnames.
o Dummy lv_check_segments() for compilation.
2002-01-10 23:21:07 +00:00

59 lines
1.1 KiB
C

/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
*/
#include "tools.h"
#include <stdio.h>
static int _backup_to_file(const char *file, struct volume_group *vg)
{
int r;
struct format_instance *tf;
if (!(tf = text_format_create(vg->cmd, file))) {
log_error("Couldn't create backup object.");
return 0;
}
if (!(r = tf->ops->vg_write(tf, vg)))
stack;
tf->ops->destroy(tf);
return r;
}
static int vg_backup_single(const char *vg_name)
{
struct volume_group *vg;
log_verbose("Checking for volume group %s", vg_name);
if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s not found", vg_name);
return ECMD_FAILED;
}
if (arg_count(file_ARG)) {
_backup_to_file(arg_value(file_ARG), vg);
} else {
/* just use the normal backup code */
backup_enable(1); /* force a backup */
if (!backup(vg)) {
stack;
return ECMD_FAILED;
}
}
log_print("Volume group %s successfully backed up.", vg_name);
return 0;
}
int vgcfgbackup(int argc, char **argv)
{
return process_each_vg(argc, argv, &vg_backup_single);
}