1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
lvm2/tools/vgcfgbackup.c
Joe Thornber e74999af51 o Add cmd_line field to struct cmd_context
o  Text format now has a description and time field at the top level.

o  archiving and backup set the description appropriately. eg,

   for an archive:

     description = "Created *before* executing 'lvextend test_vg/lvol0 -l +1'."
     creation_time = 1013166332

   for a backup:

     description = "Created *after* executing 'lvextend test_vg/lvol0 -l +1'."
     creation_time = 1013166332

This is preparing the way for a simple vgcfgundo command.
2002-02-08 11:13:47 +00:00

60 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, the_um,
vg->cmd->cmd_line))) {
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);
}