Hello *,
after backing up certain VMs I with the proxmox backup method need to save their assotiated data directories too. Those directories are on different disk volumes.
I copied the examplary hook-script to a global "bin" directory, modified it and added the script line to the vzdump config file.
Obviousliy the hook script is used - but terminates with an error. Excerpt from SYSLOG:
The modified hook script:
The code in Phase 'job-start' was entered as a test because the script aborted last time with the error message:
Any hints would be greatly appreciated,
j.
after backing up certain VMs I with the proxmox backup method need to save their assotiated data directories too. Those directories are on different disk volumes.
I copied the examplary hook-script to a global "bin" directory, modified it and added the script line to the vzdump config file.
Obviousliy the hook script is used - but terminates with an error. Excerpt from SYSLOG:
Code:
Jun 28 01:05:01 blade1 /USR/SBIN/CRON[29048]: (root) CMD (vzdump --quiet --node 1 --stop --compress --storage blade1 103)
Jun 28 01:05:03 blade1 vzdump[29048]: INFO: starting new backup job: vzdump --quiet --node 1 --stop --compress --storage blade1 103
Jun 28 01:05:03 blade1 vzdump[29048]: ERROR: command '/public/bin/hook-script.pl job-abort' failed with exit code 255
The modified hook script:
Code:
#!/usr/bin/perl -w
# example hook script for vzdump (--script option)
use strict;
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
if ($phase eq 'job-start') {
if ($vmid eq '103') {
system ("vzctl stop 103")) == 0 || print "vzctl stop for 103 failed\n";
}
if ($vmid eq '203') {
system ("vzctl stop 203")) == 0 || print "vzctl stop for 203 failed\n";
}
} elsif ( $phase eq 'job-end' || $phase eq 'job-abort') {
# 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') {
my $mode = shift; # stop/suspend/snapshot
my $vmid = shift;
my $vmtype = $ENV{VMTYPE}; # openvz/qemu
my $dumpdir = $ENV{DUMPDIR};
my $hostname = $ENV{HOSTNAME};
# tarfile is only available in phase 'backup-end'
my $tarfile = $ENV{TARFILE};
# logfile is only available in phase 'log-end'
my $logfile = $ENV{LOGFILE};
print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;hostname=$hostname;tarfile=$tarfile;logfile=$logfile\n";
if ($phase eq 'pre-restart') {
if ($vmid eq '103') {
# DB Sicherung für VM ID 103
print "Backup DB Files for 103 ...\n";
system ("/bin/sh /public/bin/savedb.sh 103") == 0 || print "Backup DB Files for 103 failed\n";
}
if ($vmid eq '203') {
# DB Sicherung für VM ID 203
print "Backup DB Files for 203 ...\n";
system ("/bin/sh /public/bin/savedb.sh 203") == 0 || print "Backup DB Files for 203 failed\n";
}
}
# example: copy resulting backup file to another host using scp
if ($phase eq 'backup-end') {
#system ("scp $tarfile 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);
The code in Phase 'job-start' was entered as a test because the script aborted last time with the error message:
Code:
Jun 26 16:07:02 INFO: Starting Backup of VM 103 (openvz)
Jun 26 16:07:02 INFO: CTID 103 exist mounted running
Jun 26 16:07:02 INFO: status = CTID 103 exist mounted running
Jun 26 16:07:02 INFO: backup mode: stop
Jun 26 16:07:02 INFO: ionice priority: 7
Jun 26 16:07:02 INFO: HOOK: backup-start stop 103
Jun 26 16:07:02 INFO: HOOK-ENV: vmtype=openvz;dumpdir=/public/openvz/blade1;hostname=dhsrv103vz;tarfile=/public/openvz/blade1/vzdump-openvz-103-2011_06_26-16_07_02.tgz;logfile=/public/openvz/blade1/vzdump-openvz-103-2011_06_26-16_07_02.log
Jun 26 16:07:02 INFO: stopping vm
Jun 26 16:07:02 INFO: HOOK: pre-stop stop 103
Jun 26 16:07:02 INFO: HOOK-ENV: vmtype=openvz;dumpdir=/public/openvz/blade1;hostname=dhsrv103vz;tarfile=/public/openvz/blade1/vzdump-openvz-103-2011_06_26-16_07_02.tgz;logfile=/public/openvz/blade1/vzdump-openvz-103-2011_06_26-16_07_02.log
Jun 26 16:07:02 INFO: Container already locked
Jun 26 16:07:02 ERROR: Backup of VM 103 failed - command 'vzctl stop 103' failed with exit code 9
Jun 26 16:07:02 INFO: HOOK: backup-abort stop 103
Jun 26 16:07:02 INFO: HOOK-ENV: vmtype=openvz;dumpdir=/public/openvz/blade1;hostname=dhsrv103vz;tarfile=/public/openvz/blade1/vzdump-openvz-103-2011_06_26-16_07_02.tgz;logfile=/public/openvz/blade1/vzdump-open
Any hints would be greatly appreciated,
j.