]> git.proxmox.com Git - pve-manager.git/blob - vzdump-hook-script.pl
update shipped appliance info index
[pve-manager.git] / vzdump-hook-script.pl
1 #!/usr/bin/perl -w
2
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'
6
7
8 use strict;
9
10 print "HOOK: " . join (' ', @ARGV) . "\n";
11
12 my $phase = shift;
13
14 if ($phase eq 'job-start' ||
15 $phase eq 'job-end' ||
16 $phase eq 'job-abort') {
17
18 my $dumpdir = $ENV{DUMPDIR};
19
20 my $storeid = $ENV{STOREID};
21
22 print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n";
23
24 # do what you want
25
26 } elsif ($phase eq 'backup-start' ||
27 $phase eq 'backup-end' ||
28 $phase eq 'backup-abort' ||
29 $phase eq 'log-end' ||
30 $phase eq 'pre-stop' ||
31 $phase eq 'pre-restart' ||
32 $phase eq 'post-restart') {
33
34 my $mode = shift; # stop/suspend/snapshot
35
36 my $vmid = shift;
37
38 my $vmtype = $ENV{VMTYPE}; # lxc/qemu
39
40 my $dumpdir = $ENV{DUMPDIR};
41
42 my $storeid = $ENV{STOREID};
43
44 my $hostname = $ENV{HOSTNAME};
45
46 # tarfile is only available in phase 'backup-end'
47 my $tarfile = $ENV{TARFILE};
48
49 # logfile is only available in phase 'log-end'
50 my $logfile = $ENV{LOGFILE};
51
52 print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;tarfile=$tarfile;logfile=$logfile\n";
53
54 # example: copy resulting backup file to another host using scp
55 if ($phase eq 'backup-end') {
56 #system ("scp $tarfile backup-host:/backup-dir") == 0 ||
57 # die "copy tar file to backup-host failed";
58 }
59
60 # example: copy resulting log file to another host using scp
61 if ($phase eq 'log-end') {
62 #system ("scp $logfile backup-host:/backup-dir") == 0 ||
63 # die "copy log file to backup-host failed";
64 }
65
66 } else {
67
68 die "got unknown phase '$phase'";
69
70 }
71
72 exit (0);