X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=vzdump-hook-script.pl;h=4d530cef47a558dbb1b05720748c8bad0872bfd5;hb=463b9b8219014e43121621d1aba52e6319ebf966;hp=4be46211f3ed6e262a0d4b958f30bb7aa0f12b3e;hpb=971e4bb13e3de186a86e27cb1cee464e263c50a8;p=pve-manager.git diff --git a/vzdump-hook-script.pl b/vzdump-hook-script.pl index 4be46211..4d530cef 100755 --- a/vzdump-hook-script.pl +++ b/vzdump-hook-script.pl @@ -11,15 +11,30 @@ print "HOOK: " . join (' ', @ARGV) . "\n"; my $phase = shift; -if ($phase eq 'job-start' || +if ($phase eq 'job-init' || + $phase eq 'job-start' || $phase eq 'job-end' || $phase eq 'job-abort') { + # undef for Proxmox Backup Server storages + # undef in phase 'job-init' except when --dumpdir is used directly my $dumpdir = $ENV{DUMPDIR}; + # undef when --dumpdir is used directly my $storeid = $ENV{STOREID}; - print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n"; + print "HOOK-ENV: "; + print "dumpdir=$dumpdir;" if defined($dumpdir); + print "storeid=$storeid;" if defined($storeid); + print "\n"; + + # example: wake up remote storage node and enable storage + if ($phase eq 'job-init') { + #system("wakeonlan AA:BB:CC:DD:EE:FF"); + #sleep(30); + #system ("/sbin/pvesm set $storeid --disable 0") == 0 || + # die "enabling storage $storeid failed"; + } # do what you want @@ -37,23 +52,30 @@ if ($phase eq 'job-start' || my $vmtype = $ENV{VMTYPE}; # lxc/qemu + # undef for Proxmox Backup Server storages my $dumpdir = $ENV{DUMPDIR}; + # undef when --dumpdir is used directly my $storeid = $ENV{STOREID}; my $hostname = $ENV{HOSTNAME}; - # tarfile is only available in phase 'backup-end' - my $tarfile = $ENV{TARFILE}; + # target is only available in phase 'backup-end' + my $target = $ENV{TARGET}; # logfile is only available in phase 'log-end' + # undef for Proxmox Backup Server storages my $logfile = $ENV{LOGFILE}; - print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;tarfile=$tarfile;logfile=$logfile\n"; + print "HOOK-ENV: "; + for my $var (qw(vmtype dumpdir storeid hostname target logfile)) { + print "$var=$ENV{uc($var)};" if defined($ENV{uc($var)}); + } + print "\n"; # example: copy resulting backup file to another host using scp if ($phase eq 'backup-end') { - #system ("scp $tarfile backup-host:/backup-dir") == 0 || + #system ("scp $target backup-host:/backup-dir") == 0 || # die "copy tar file to backup-host failed"; }