vzdump-hook-script not working as expected

jors

Member
Apr 10, 2012
21
2
23
Hi there,

We are trying to use a vzdump hook script to do some things. We have a Proxmox cluster setup with several hypervisors. We took a look at /usr/share/doc/pve-manager/examples/vzdump-hook-script.pl and made an adaptation:

Bash:
#!/bin/bash

LIST_BORG_BACKUPS=${DUMPDIR}/list_borg_backups
CONTROL_JOB=${DUMPDIR}/control_job_`hostname`

if [ "$1" == "job-start" ]; then # vzdump started on a hipervisor
        echo "start" > $CONTROL_JOB
        echo "`date` Started `hostname`" >> $LIST_BORG_BACKUPS
elif [ "$1" == "backup-end" ]; then # Some VM backup ended
        echo $TARFILE >> $LIST_BORG_BACKUPS
elif [ "$1" == "job-end" -o "$1" == "job-abort"]; then # vzdump ended on a hipervisor
        echo "stop" > $CONTROL_JOB
        echo "`date` Stopped `hostname`" >> $LIST_BORG_BACKUPS
        # If there are no vzdump jobs, log it
        grep -q "start" ${DUMPDIR}/control_job_*
        if [ $? -eq 1 ]; then
                echo "No vzdump jobs left" >> $LIST_BORG_BACKUPS
        fi
fi

So our goal is to register the start and end backup job for each hypervisor and also the end backup for every VM. And when there's no vzdump job left, we also register that (shoud be the last line of the log). We would expect something like this in log file LIST_BORG_BACKUPS=${DUMPDIR}/list_borg_backups:
Code:
Tue Jun 23 22:00:02 CEST 2020 Started proxmox1
Tue Jun 23 22:00:03 CEST 2020 Started proxmox2
Tue Jun 23 22:00:03 CEST 2020 Started proxmox3
/mnt/backups/dump/vzdump-qemu-100-2020_06_23-22_00_02.vma.lzo
/mnt/backups/dump/vzdump-qemu-200-2020_06_23-22_00_03.vma.lzo
/mnt/backups/dump/vzdump-qemu-300-2020_06_23-22_00_02.vma.lzo
Tue Jun 23 23:00:00 CEST 2020 Stopped proxmox1
Tue Jun 23 23:30:00 CEST 2020 Stopped proxmox2
Tue Jun 23 23:40:00 CEST 2020 Stopped proxmox3
No vzdump jobs left

What we are getting instead is something like this:
Code:
Tue Jun 23 22:00:02 CEST 2020 Started proxmox1
Tue Jun 23 22:00:02 CEST 2020 Started proxmox2
Tue Jun 23 22:00:03 CEST 2020 Started proxmox3
/mnt/pve/backups/dump/vzdump-qemu-100-2020_06_23-22_00_02.vma.lzo
/mnt/pve/backups/dump/vzdump-qemu-200-2020_06_23-22_00_03.vma.lzo
/mnt/pve/backups/dump/vzdump-qemu-300-2020_06_23-22_00_02.vma.lzo

We are not getting registered the job-end and job-abort ("Stopped"), so we also aren't getting the "No vzdump jobs left" either.

Why is that? What are we missing?

Kind regards.
 
Nevermind, was a bash sintax error :D

Bash:
elif [ "$1" == "job-end" -o "$1" == "job-abort"];

Should be:

Bash:
elif [ "$1" == "job-end" -o "$1" == "job-abort" ];

Note the space between "job-abort" and ].

Kind regards.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!