vzdump hook script is being ignored

kobuki

Renowned Member
Dec 30, 2008
473
27
93
I'm running my vzdump backups using a simple hook script. It always gets to run when starting vzdump from the command line but never when the backups are started from cron (configured via the web interface). Am I doing something wrong?

This is my config:

Code:
# pveversion -v
pve-manager: 2.1-1 (pve-manager/2.1/f9b0f63a)
running kernel: 2.6.32-12-pve
proxmox-ve-2.6.32: 2.1-68
pve-kernel-2.6.32-12-pve: 2.6.32-68
lvm2: 2.02.95-1pve2
clvm: 2.02.95-1pve2
corosync-pve: 1.4.3-1
openais-pve: 1.1.4-2
libqb: 0.10.1-2
redhat-cluster-pve: 3.1.8-3
resource-agents-pve: 3.9.2-3
fence-agents-pve: 3.1.7-2
pve-cluster: 1.0-26
qemu-server: 2.0-39
pve-firmware: 1.0-16
libpve-common-perl: 1.0-27
libpve-access-control: 1.0-21
libpve-storage-perl: 2.0-18
vncterm: 1.0-2
vzctl: 3.0.30-2pve5
vzprocps: 2.0.11-2
vzquota: 3.0.12-3
pve-qemu-kvm: 1.0-9
ksm-control-daemon: 1.1-1

# cat /etc/vzdump.conf
# vzdump default settings

#tmpdir: DIR
#dumpdir: DIR
storage: vzdump
#mode: snapshot|suspend|stop
#bwlimit: KBPS
#ionice: PRI
#lockwait: MINUTES
#stopwait: MINUTES
#size: MB
maxfiles: 3
script: /etc/vzdump-hook-script.sh
#exclude-path: PATHLIST

# cat /etc/vzdump-hook-script.sh
#! /bin/bash

if [ "$1" == "backup-start" ]; then
  echo Hostname: $HOSTNAME
fi
 
I use hook scripts to mount/unmount an encrypted disk to store the backup files.

Your vzdump.conf file looks correct.
Your hook script looks correct too.

My best guess as to why it works on the command line but not from cron is that the PATH or shell(ie. dash vs bash) is different in cron vs command line.
 
Thanks, you lead me to the right path to verify dash's ways. While $PATH is the same in both, there indeed exists some incompatibility between bash and dash. The `if` in the script above must be written as:
Code:
if [ "$1" = "backup-start" ]; then
  echo Hostname: $HOSTNAME
fi
That is, with a single equal sign. Otherwise it throws a fit and won't run. It is supposed to be caused by dash's strict posix adherence. Unfortunately it is not logged anywhere during backup. On the other hand, the shebang explicitly specifies that the script is to be run using bash. I'll see todays daily run of the backup.
 
Well, it still doesn't work. I'm putting log lines in the sript in case it ever gets to run during cron backup. Anyone has an idea? The cron line is using the `--quiet 1` parameter, maybe this has to do something with it? Shouldn't it just quiet vzdump so it only puts messages to its logs and not stdout too?
 
OK, my script is running, no problem there, I could verify it. But the informative line I want to appear in the log output is not in the log. I guess it's a bug. Or is there a way to make extra log lines (that is, lines written to stdout) appear in the vzdump logs that get created with the archives?
 
Dietmar, thanks for your attention. But if you look at my previous posts carefully it has been stated already that the script is running in bash and after a quick fix, in dash too. So let me repeat the problem at hand. The script is indeed running (no bugs), but its standard output is not being recorded in the .log file pertaining to the vzdump archive. I can see this output when I run the vzdump command from the command line. So something mut be different when vzdump is run via cron as configured in the web interface. Since it's inconsistent in behaviour, I'd say it's a bug in either vzdump or the procedure that is being used to run it via cron.

I'd be glad to provide you any debugging info would you need any.
 
Last edited:
I removed the `--quiet 1` parameter from this night's run of the backup, the output is still not written to the log files. I need this possibility, please advise on how to achieve this (if this is the expected behaviour).
 
Alright, I think I've found the problem. Using vzdump snapshot mode, there's no `backup-start` phase, only `pre-stop`. Although there is `backup-stop` besides `pre-restart`. Something is not right with the phases. Shall I submit a vzdump issue?
 

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!