]> git.proxmox.com Git - pve-storage.git/commitdiff
Fix: backup: relax file name matching regex
authorAlwin Antreich <a.antreich@proxmox.com>
Tue, 12 May 2020 15:12:13 +0000 (17:12 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 May 2020 16:12:01 +0000 (18:12 +0200)
The rework of the backup file detection logic missed the non-standard
file name case. This patch allows to restore backups with different file
names. Though the config extraction fails, since the type is unknown.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/Storage.pm
test/archive_info_test.pm

index 87550b14360eade1ac15a5de96272b3e64ab2e3a..2a8deaf29dd446832d19783d08b778ed8baa90cb 100755 (executable)
@@ -1394,9 +1394,13 @@ sub archive_info {
     my $info;
 
     my $volid = basename($archive);
-    if ($volid =~ /vzdump-(lxc|openvz|qemu)-\d+-(?:\d{4})_(?:\d{2})_(?:\d{2})-(?:\d{2})_(?:\d{2})_(?:\d{2})\.(tgz$|tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?$/) {
-       $info = decompressor_info($2, $3);
-       $info->{type} = $1;
+    if ($volid =~ /\.(tgz$|tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?$/) {
+       $info = decompressor_info($1, $2);
+       $info->{type} = 'unknown';
+
+       if ($volid =~ /vzdump-(lxc|openvz|qemu)-\d+-(?:\d{4})_(?:\d{2})_(?:\d{2})-(?:\d{2})_(?:\d{2})_(?:\d{2})/) {
+           $info->{type} = $1;
+       }
     } else {
        die "ERROR: couldn't determine format and compression type\n";
     }
index 283fe47a266df97b49668c4196fa19e92149292a..7db02d1d52cc56c391e3bbb8ab947fb93920dd6f 100644 (file)
@@ -38,6 +38,16 @@ my $tests = [
            'compression'  => 'gz',
        },
     },
+    {
+       description => 'Backup archive, none, tgz',
+       archive     => "backup/whatever-the-name_is_here.tgz",
+       expected    => {
+           'type'         => 'unknown',
+           'format'       => 'tar',
+           'decompressor' => ['tar', '-z'],
+           'compression'  => 'gz',
+       },
+    },
 ];
 
 # add new compression fromats to test
@@ -88,7 +98,6 @@ my $non_bkp_suffix = {
     'openvz' => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
     'lxc'    => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
     'qemu'   => [ 'vma.xz', 'vms.gz', 'vmx.zst', '', ],
-    'none'   => [ 'tar.gz', ],
 };
 
 # create tests for failed matches