[pve-devel] [PATCH storage] Fix: backup: relax file name matching regex

Thomas Lamprecht t.lamprecht at proxmox.com
Fri May 15 19:35:13 CEST 2020


On 5/12/20 5:12 PM, Alwin Antreich wrote:
> 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 at proxmox.com>
> ---
> Note: This fixes the issue reported on the forum.
>       https://forum.proxmox.com/threads/proxmox-zst-backup-format-cant-be-restored-from-gui.69643/
> 

hmm does it though? It breaks recognizing their VM backup as such (qemu)
even though the followed that part of the naming scheme just fine..

I mean, I can see why the "getting strict" was happening but not why we
have to go in the complete opposite direction that far again instead of
going back where we came from.. Applied, but followed up with enforcing
at least the "vzdump-(qemu|...)-$vmid part.

>  PVE/Storage.pm            | 10 +++++++---
>  test/archive_info_test.pm | 11 ++++++++++-
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 87550b1..2a8deaf 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -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";
>      }
> diff --git a/test/archive_info_test.pm b/test/archive_info_test.pm
> index 283fe47..7db02d1 100644
> --- a/test/archive_info_test.pm
> +++ b/test/archive_info_test.pm
> @@ -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
> 





More information about the pve-devel mailing list