]> git.proxmox.com Git - pmg-api.git/commitdiff
Restore: optionally restore from directory
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 28 Oct 2020 18:54:21 +0000 (19:54 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 30 Oct 2020 06:22:55 +0000 (07:22 +0100)
In preparation for integrating PMG with PBS decide based on the type of the
provided filename, whether or not to untar:
* if it's a directory skip untarring (PBS)
* if it's a filename untar (local backup)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/Backup.pm

index c9739f27baf771b5a195119d6daec2730b7b4c99..3745015df17002da9aea6431f06ba03092f89e39 100644 (file)
@@ -243,12 +243,23 @@ sub pmg_restore {
     my $tarfn = "config_backup.tar";
     my $sigfn = "proxmox_backup_v1.md5";
 
+    my $untar = 1;
+
+    # directory indicates that the files were restored from a PBS remote
+    if ( -d $filename ) {
+       $dirname = $filename;
+       $untar = 0;
+    }
+
     eval {
-       # create a temporary directory
-       mkdir $dirname;
 
-       system("cd $dirname; tar xzf $filename >/dev/null 2>&1") == 0 ||
-           die "unable to extract backup archive: ERROR";
+       if ($untar) {
+           # create a temporary directory
+           mkdir $dirname;
+
+           system("cd $dirname; tar xzf $filename >/dev/null 2>&1") == 0 ||
+               die "unable to extract backup archive: ERROR";
+       }
 
        system("cd $dirname; md5sum -c $sigfn") == 0 ||
            die "proxmox backup signature check failed: ERROR";