I
ieldib
Guest
Hi All,
I am trying to add the CTID hostname (openvz containers) to the backup files that are created on these containers. I tried using a hookfile which had no effect while passing the --script hookfile.pl . Can anyone assist ? This is an annoying problem as a container that has CTID 110 can be retaken by a new container if that previous container is destroyed.
#!/usr/bin/perl -w
# example hook script for vzdump (--script option)
use strict;
use File::Copy qw(move);
my $basedir="/mnt/backups/";
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
if ($phase eq 'backup-end' ){
my $mode = shift; # stop/suspend/snapshot
my $vmid = shift;
my $vmtype = $ENV{VMTYPE} if defined ($ENV{VMTYPE}); # openvz/qemu
my $dumpdir = $ENV{DUMPDIR} if defined ($ENV{DUMPDIR});
my $hostname = $ENV{HOSTNAME} if defined ($ENV{HOSTNAME});
# tarfile is only available in phase 'backup-end'
my $tarfile = $ENV{TARFILE} if defined ($ENV{TARFILE});
# logfile is only available in phase 'log-end'
my $logfile = $ENV{LOGFILE} if defined ($ENV{LOGFILE});
print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;hostname=$hostname;tarfile=$tarfile;logfile=$logfile\n";
if ($phase eq 'backup-end' and defined ($tarfile) and defined ($hostname)) {
if ( $tarfile=~/($basedir\/vzdump-(qemu|openvz)-\d+-)(\d\d\d\d_.+)/ ){
my $tarfile2=$1.$hostname."-".$3;
print "HOOK: Renaming file $tarfile to $tarfile2\n";
move $tarfile, $tarfile2;
}
}
}
exit (0);
I am trying to add the CTID hostname (openvz containers) to the backup files that are created on these containers. I tried using a hookfile which had no effect while passing the --script hookfile.pl . Can anyone assist ? This is an annoying problem as a container that has CTID 110 can be retaken by a new container if that previous container is destroyed.
#!/usr/bin/perl -w
# example hook script for vzdump (--script option)
use strict;
use File::Copy qw(move);
my $basedir="/mnt/backups/";
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
if ($phase eq 'backup-end' ){
my $mode = shift; # stop/suspend/snapshot
my $vmid = shift;
my $vmtype = $ENV{VMTYPE} if defined ($ENV{VMTYPE}); # openvz/qemu
my $dumpdir = $ENV{DUMPDIR} if defined ($ENV{DUMPDIR});
my $hostname = $ENV{HOSTNAME} if defined ($ENV{HOSTNAME});
# tarfile is only available in phase 'backup-end'
my $tarfile = $ENV{TARFILE} if defined ($ENV{TARFILE});
# logfile is only available in phase 'log-end'
my $logfile = $ENV{LOGFILE} if defined ($ENV{LOGFILE});
print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;hostname=$hostname;tarfile=$tarfile;logfile=$logfile\n";
if ($phase eq 'backup-end' and defined ($tarfile) and defined ($hostname)) {
if ( $tarfile=~/($basedir\/vzdump-(qemu|openvz)-\d+-)(\d\d\d\d_.+)/ ){
my $tarfile2=$1.$hostname."-".$3;
print "HOOK: Renaming file $tarfile to $tarfile2\n";
move $tarfile, $tarfile2;
}
}
}
exit (0);