mirror of
				https://git.proxmox.com/git/pve-manager
				synced 2025-11-04 05:23:04 +00:00 
			
		
		
		
	with the change introduced in 6cba1855d8 the
exported variable name changed from tarfile to target.
this patch reflects the renaming in the example hook script.
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
		
	
			
		
			
				
	
	
		
			73 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/perl -w
 | 
						|
 | 
						|
# Example hook script for vzdump (--script option)
 | 
						|
# This can also be added as a line in /etc/vzdump.conf
 | 
						|
# e.g. 'script: /usr/local/bin/vzdump-hook-script.pl'
 | 
						|
 | 
						|
 | 
						|
use strict;
 | 
						|
 | 
						|
print "HOOK: " . join (' ', @ARGV) . "\n";
 | 
						|
 | 
						|
my $phase = shift;
 | 
						|
 | 
						|
if ($phase eq 'job-start' ||
 | 
						|
    $phase eq 'job-end'  ||
 | 
						|
    $phase eq 'job-abort') {
 | 
						|
 | 
						|
    my $dumpdir = $ENV{DUMPDIR};
 | 
						|
 | 
						|
    my $storeid = $ENV{STOREID};
 | 
						|
 | 
						|
    print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n";
 | 
						|
 | 
						|
    # do what you want
 | 
						|
 | 
						|
} elsif ($phase eq 'backup-start' ||
 | 
						|
	 $phase eq 'backup-end' ||
 | 
						|
	 $phase eq 'backup-abort' ||
 | 
						|
	 $phase eq 'log-end' ||
 | 
						|
	 $phase eq 'pre-stop' ||
 | 
						|
	 $phase eq 'pre-restart' ||
 | 
						|
	 $phase eq 'post-restart') {
 | 
						|
 | 
						|
    my $mode = shift; # stop/suspend/snapshot
 | 
						|
 | 
						|
    my $vmid = shift;
 | 
						|
 | 
						|
    my $vmtype = $ENV{VMTYPE}; # lxc/qemu
 | 
						|
 | 
						|
    my $dumpdir = $ENV{DUMPDIR};
 | 
						|
 | 
						|
    my $storeid = $ENV{STOREID};
 | 
						|
 | 
						|
    my $hostname = $ENV{HOSTNAME};
 | 
						|
 | 
						|
    # target is only available in phase 'backup-end'
 | 
						|
    my $target = $ENV{TARGET};
 | 
						|
 | 
						|
    # logfile is only available in phase 'log-end'
 | 
						|
    my $logfile = $ENV{LOGFILE};
 | 
						|
 | 
						|
    print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;target=$target;logfile=$logfile\n";
 | 
						|
 | 
						|
    # example: copy resulting backup file to another host using scp
 | 
						|
    if ($phase eq 'backup-end') {
 | 
						|
        #system ("scp $target backup-host:/backup-dir") == 0 ||
 | 
						|
        #    die "copy tar file to backup-host failed";
 | 
						|
    }
 | 
						|
 | 
						|
    # example: copy resulting log file to another host using scp
 | 
						|
    if ($phase eq 'log-end') {
 | 
						|
        #system ("scp $logfile backup-host:/backup-dir") == 0 ||
 | 
						|
        #    die "copy log file to backup-host failed";
 | 
						|
    }
 | 
						|
 | 
						|
} else {
 | 
						|
 | 
						|
    die "got unknown phase '$phase'";
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
exit (0);
 |