[pve-devel] vma extract force flag
Ben Dailey
bdailey at bhmsd.org
Wed Apr 24 22:44:41 CEST 2024
Would the development team consider a patch like below to add a force flag
to the vma extract command?
diff --git
a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
index 1620a56..931bebc 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
@@ -1797,7 +1797,7 @@ index 0000000000..347f6283ca
+ "vma list <filename>\n"
+ "vma config <filename> [-c config]\n"
+ "vma create <filename> [-c config] pathname ...\n"
-+ "vma extract <filename> [-d <drive-list>] [-r <fifo>]
<targetdir>\n"
++ "vma extract <filename> [-d <drive-list>] [-r <fifo>] [-f]
<targetdir>\n"
+ "vma verify <filename> [-v]\n"
+ ;
+
@@ -1939,6 +1939,7 @@ index 0000000000..347f6283ca
+{
+ int c, ret = 0;
+ int verbose = 0;
++ int force = 0;
+ const char *filename;
+ const char *dirname;
+ const char *readmap = NULL;
@@ -1957,6 +1958,9 @@ index 0000000000..347f6283ca
+ case 'd':
+ drive_list = g_strsplit(optarg, ",", 254);
+ break;
++ case 'f':
++ force = 1;
++ break;
+ case 'r':
+ readmap = optarg;
+ break;
@@ -1982,7 +1986,7 @@ index 0000000000..347f6283ca
+ g_error("%s", error_get_pretty(errp));
+ }
+
-+ if (mkdir(dirname, 0777) < 0) {
++ if (mkdir(dirname, 0777) < 0 && !force) {
+ g_error("unable to create target directory %s - %s",
+ dirname, g_strerror(errno));
+ }
@@ -2100,7 +2104,13 @@ index 0000000000..347f6283ca
+ VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
+ if (di && (strcmp(di->devname, "vmstate") == 0)) {
+ char *statefn = g_strdup_printf("%s/vmstate.bin", dirname);
-+ vmstate_fd = open(statefn, O_WRONLY|O_CREAT|O_EXCL, 0644);
++ int open_flags =O_WRONLY|O_CREAT;
++ if(force) {
++ open_flags |= O_TRUNC;
++ }else{
++ open_flags |= O_EXCL;
++ }
++ vmstate_fd = open(statefn, open_flags, 0644);
+ if (vmstate_fd < 0) {
+ g_error("create vmstate file '%s' failed - %s", statefn,
+ g_strerror(errno));
I would like to keep extracted backups on an NFS server backed with ZFS and
retain the benefits of differential snapshots and it would be helpful to
have the vma extract replace the previous backups directly.
Thank you for your consideration.
Praise the Lord!
Ben Dailey
Associate Technology Director
Bluffton-Harrison MSD
bdailey at bhmsd.org
More information about the pve-devel
mailing list