From c855ac150cb150668754f4154327de1f5b5603de Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 19 Feb 2020 13:55:28 +0100 Subject: [PATCH] implement extract_vzdump_config for PBSPlugin --- PVE/Storage.pm | 9 +++++++++ PVE/Storage/PBSPlugin.pm | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 17196a8..2a5295f 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -1370,6 +1370,15 @@ sub extract_vzdump_config_vma { sub extract_vzdump_config { my ($cfg, $volid) = @_; + my ($storeid, $volname) = parse_volume_id($volid); + if (defined($storeid)) { + my $scfg = storage_config($cfg, $storeid); + if ($scfg->{type} eq 'pbs') { + storage_check_enabled($cfg, $storeid); + return PVE::Storage::PBSPlugin->extract_vzdump_config($scfg, $volname, $storeid); + } + } + my $archive = abs_filesystem_path($cfg, $volid); if ($volid =~ /vzdump-(lxc|openvz)-\d+-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|(tar(\.(gz|lzo))?))$/) { diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm index 7142474..1149cd8 100644 --- a/PVE/Storage/PBSPlugin.pm +++ b/PVE/Storage/PBSPlugin.pm @@ -144,6 +144,33 @@ sub run_client_cmd { # Storage implementation +sub extract_vzdump_config { + my ($class, $scfg, $volname, $storeid) = @_; + + my ($vtype, $name, $vmid, undef, undef, undef, $format) = $class->parse_volname($volname); + + my $config = ''; + + my $outfunc = sub { + my $line = shift; + $config .= "$line\n"; + }; + + my $config_name; + if ($format eq 'pbs-vm') { + $config_name = 'qemu-server.conf'; + } elsif ($format eq 'pbs-ct') { + $config_name = 'pct.conf'; + } else { + die "unable to extract configuration for backup format '$format'\n"; + } + + run_raw_client_cmd(undef, $scfg, $storeid, 'restore', [ $name, $config_name, '-' ], + outfunc => $outfunc, errmsg => 'proxmox-backup-client failed'); + + return $config; +} + sub on_add_hook { my ($class, $storeid, $scfg, %param) = @_;