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