summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/format_text/archive.c16
-rw-r--r--lib/format_text/archiver.c11
-rw-r--r--lib/format_text/archiver.h1
-rw-r--r--lib/format_text/format-text.h1
-rw-r--r--tools/vgcfgrestore.c21
6 files changed, 41 insertions, 10 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index f74610dc9..9a5efd2af 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.26 -
=================================
+ Allow vgcfgrestore to list metadata backup files using -f
Add vg_check_status to consolidate vg status checks and error messages.
Add pvdisplay --maps implementation.
Fix vgcfgrestore man pg to show mandatory VG name and remove LVM1 options.
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index c42581c16..ca94c7424 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -362,6 +362,22 @@ int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
return 1;
}
+int archive_list_file(struct cmd_context *cmd, const char *file)
+{
+ struct archive_file af;
+
+ af.path = (char *)file;
+
+ if (!path_exists(af.path)) {
+ log_err("Archive file %s not found.", af.path);
+ return 0;
+ }
+
+ _display_archive(cmd, &af);
+
+ return 1;
+}
+
int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
{
struct archive_file af;
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index f99069fe5..f3aac657b 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -148,6 +148,17 @@ int archive_display(struct cmd_context *cmd, const char *vg_name)
return r1 && r2;
}
+int archive_display_file(struct cmd_context *cmd, const char *file)
+{
+ int r;
+
+ init_partial(1);
+ r = archive_list_file(cmd, file);
+ init_partial(0);
+
+ return r;
+}
+
int backup_init(struct cmd_context *cmd, const char *dir)
{
if (!(cmd->backup_params = dm_pool_zalloc(cmd->libmem,
diff --git a/lib/format_text/archiver.h b/lib/format_text/archiver.h
index 1e45d9ad7..af7cfbd25 100644
--- a/lib/format_text/archiver.h
+++ b/lib/format_text/archiver.h
@@ -38,6 +38,7 @@ void archive_exit(struct cmd_context *cmd);
void archive_enable(struct cmd_context *cmd, int flag);
int archive(struct volume_group *vg);
int archive_display(struct cmd_context *cmd, const char *vg_name);
+int archive_display_file(struct cmd_context *cmd, const char *file);
int backup_init(struct cmd_context *cmd, const char *dir);
void backup_exit(struct cmd_context *cmd);
diff --git a/lib/format_text/format-text.h b/lib/format_text/format-text.h
index c38b88e45..2a690454e 100644
--- a/lib/format_text/format-text.h
+++ b/lib/format_text/format-text.h
@@ -33,6 +33,7 @@ int archive_vg(struct volume_group *vg,
* Displays a list of vg backups in a particular archive directory.
*/
int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname);
+int archive_list_file(struct cmd_context *cmd, const char *file);
int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname);
/*
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index 3dd1c676b..83b42f094 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -19,26 +19,27 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
{
char *vg_name;
- if (argc != 1) {
+ if (argc == 1) {
+ vg_name = skip_dev_dir(cmd, argv[0], NULL);
+ if (!validate_name(vg_name)) {
+ log_error("Volume group name \"%s\" is invalid", vg_name);
+ return ECMD_FAILED;
+ }
+ } else if (!(arg_count(cmd, list_ARG) && arg_count(cmd, file_ARG))) {
log_err("Please specify a *single* volume group to restore.");
return ECMD_FAILED;
}
- vg_name = skip_dev_dir(cmd, argv[0], NULL);
-
- if (!validate_name(vg_name)) {
- log_error("Volume group name \"%s\" is invalid", vg_name);
- return ECMD_FAILED;
- }
-
/*
* FIXME: overloading the -l arg for now to display a
* list of archive files for a particular vg
*/
if (arg_count(cmd, list_ARG)) {
- if (!archive_display(cmd, vg_name))
+ if (!(arg_count(cmd,file_ARG) ?
+ archive_display_file(cmd,
+ arg_str_value(cmd, file_ARG, "")) :
+ archive_display(cmd, vg_name)))
return ECMD_FAILED;
-
return ECMD_PROCESSED;
}