]>
git.proxmox.com Git - pve-manager.git/blob - vzdump-hook-script.pl
3 # Example hook script for vzdump (--script option)
4 # This can also be added as a line in /etc/vzdump.conf
5 # e.g. 'script: /usr/local/bin/vzdump-hook-script.pl'
10 print "HOOK: " . join (' ', @ARGV) . "\n";
14 if ($phase eq 'job-init' ||
15 $phase eq 'job-start' ||
16 $phase eq 'job-end' ||
17 $phase eq 'job-abort') {
19 # undef for Proxmox Backup Server storages
20 # undef in phase 'job-init' except when --dumpdir is used directly
21 my $dumpdir = $ENV{DUMPDIR
};
23 # undef when --dumpdir is used directly
24 my $storeid = $ENV{STOREID
};
27 print "dumpdir=$dumpdir;" if defined($dumpdir);
28 print "storeid=$storeid;" if defined($storeid);
31 # example: wake up remote storage node and enable storage
32 if ($phase eq 'job-init') {
33 #system("wakeonlan AA:BB:CC:DD:EE:FF");
35 #system ("/sbin/pvesm set $storeid --disable 0") == 0 ||
36 # die "enabling storage $storeid failed";
41 } elsif ($phase eq 'backup-start' ||
42 $phase eq 'backup-end' ||
43 $phase eq 'backup-abort' ||
44 $phase eq 'log-end' ||
45 $phase eq 'pre-stop' ||
46 $phase eq 'pre-restart' ||
47 $phase eq 'post-restart') {
49 my $mode = shift; # stop/suspend/snapshot
53 my $vmtype = $ENV{VMTYPE
}; # lxc/qemu
55 # undef for Proxmox Backup Server storages
56 my $dumpdir = $ENV{DUMPDIR
};
58 # undef when --dumpdir is used directly
59 my $storeid = $ENV{STOREID
};
61 my $hostname = $ENV{HOSTNAME
};
63 # target is only available in phase 'backup-end'
64 my $target = $ENV{TARGET
};
66 # logfile is only available in phase 'log-end'
67 # undef for Proxmox Backup Server storages
68 my $logfile = $ENV{LOGFILE
};
71 for my $var (qw(vmtype dumpdir storeid hostname target logfile)) {
72 print "$var=$ENV{uc($var)};" if defined($ENV{uc($var)});
76 # example: copy resulting backup file to another host using scp
77 if ($phase eq 'backup-end') {
78 #system ("scp $target backup-host:/backup-dir") == 0 ||
79 # die "copy tar file to backup-host failed";
82 # example: copy resulting log file to another host using scp
83 if ($phase eq 'log-end') {
84 #system ("scp $logfile backup-host:/backup-dir") == 0 ||
85 # die "copy log file to backup-host failed";
90 die "got unknown phase '$phase'";