VZDUMP Hook Script fails

shatter

Member
Nov 27, 2009
74
0
6
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:
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.
 
The script without the "stop" code results in:

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-openvz-103-2011_06_26-16_07_02.log

Why the "Container already locked".
The backup aborts with exit code 9.

j.
 
I simply do not understand what you are trying to do. I make no sense to execute 'vzctl stop' inside the hook skipt, because you run vzdump in stop mode.
 
I simply do not understand what you are trying to do. I make no sense to execute 'vzctl stop' inside the hook skipt, because you run vzdump in stop mode.

Hi Dietmar,

that was just test code. I removed it and still get the message
Code:
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

Exit code 9 means another vzctl command is working ... but I can't identify one.

The same script with VM 203 - which is a clone of 103 - runs fine.

Joachim
 
I just uploaded a fix to the pvetest repository. Please can you test?

# wget ftp://download.proxmox.com/debian/dists/lenny/pvetest/binary-amd64/vzdump_1.2-14_all.deb
# wget ftp://download.proxmox.com/debian/dists/lenny/pvetest/binary-amd64/vzctl_3.0.28-1pve1_amd64.deb
# dpkg -i vzctl_3.0.28-1pve1_amd64.deb vzdump_1.2-14_all.deb

Does that solve the problem?

I'm running a backup test on the 203 machine now, which is our DB test system. That runs just fine.
The problem arose on the production system - which means I can run the test tonight only. I will do so.

But I installed the new package on the production blade, getting:
Code:
blade1:~# dpkg -i vzctl_3.0.28-1pve1_amd64.deb vzdump_1.2-14_all.deb
(Reading database ... 30828 files and directories currently installed.)
Preparing to replace vzctl 3.0.27-1pve1 (using vzctl_3.0.28-1pve1_amd64.deb) ...
Unpacking replacement vzctl ...
Preparing to replace vzdump 1.2-13 (using vzdump_1.2-14_all.deb) ...
Unpacking replacement vzdump ...
Setting up vzctl (3.0.28-1pve1) ...
Installing new version of config file /etc/init.d/vzeventd ...
Installing new version of config file /etc/vz/conf/ve-basic.conf-sample ...
Installing new version of config file /etc/vz/conf/ve-vswap-256m.conf-sample ...
Installing new version of config file /etc/vz/conf/ve-vswap-1024m.conf-sample ...
Installing new version of config file /etc/vz/conf/ve-unlimited.conf-sample ...
Installing new version of config file /etc/vz/conf/ve-vswap-512m.conf-sample ...
Installing new version of config file /etc/vz/conf/ve-light.conf-sample ...
Installing new version of config file /etc/vz/dists/scripts/set_ugid_quota.sh ...
Installing new version of config file /etc/vz/dists/scripts/arch-set_ugid_quota.sh ...
Installing new version of config file /etc/vz/dists/scripts/gentoo-set_ugid_quota.sh ...
Installing new version of config file /etc/vz/dists/scripts/arch-add_ip.sh ...
Installing new version of config file /etc/vz/dists/scripts/slackware-set_ugid_quota.sh ...
Installing new version of config file /etc/vz/osrelease.conf ...
[B]FATAL: Module vzevent not found.
Checking vzevent kernel module .....failed
OpenVZ already running..failed
[/B]Processing triggers for man-db ...
Setting up vzdump (1.2-14) ...
blade1:~#

Is the installation still OK?


Joachim
 
do you run a current kernel? post the output of 'pveversion -v'
 
Code:
blade1:/public/bin# pveversion -v
pve-manager: 1.8-18 (pve-manager/1.8/6070)
running kernel: 2.6.32-3-pve
proxmox-ve-2.6.32: 1.8-33
pve-kernel-2.6.32-3-pve: 2.6.32-14
pve-kernel-2.6.32-4-pve: 2.6.32-33
pve-kernel-2.6.18-2-pve: 2.6.18-5
qemu-server: 1.1-30
pve-firmware: 1.0-11
libpve-storage-perl: 1.0-17
vncterm: 0.9-2
vzctl: 3.0.28-1pve1
vzdump: 1.2-14
vzprocps: 2.0.11-2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.14.1-1
ksm-control-daemon: 1.0-6


Code:
/boot/grub/menu.lst:

## ## End Default Options ##

title           Proxmox Virtual Environment, kernel 2.6.32-4-pve
root            (hd0,0)
kernel          /vmlinuz-2.6.32-4-pve root=/dev/mapper/pve-root ro
initrd          /initrd.img-2.6.32-4-pve

title           Proxmox Virtual Environment, kernel 2.6.32-3-pve
root            (hd0,0)
kernel          /vmlinuz-2.6.32-3-pve root=/dev/mapper/pve-root ro
initrd          /initrd.img-2.6.32-3-pve

title           Proxmox Virtual Environment, kernel memtest86+
root            (hd0,0)
kernel          /memtest86+.bin

### END DEBIAN AUTOMAGIC KERNELS LIST


"menu.lst" line 124 of 136 --91%-- col 1

Looks like I have to reboot the blade - tonight.

j.
 
Last edited:
yes, you running kernel does not support vzeventd.