We have been using Proxmox in a simple production environment for a few weeks. So far I have preferred using "stop" mode for backups as I worry about data consistency if we ever needed to restore a service from a running snapshot. I don't have experience with snapshot style backups, and it seems to me that our system relies quite a bit on a consistent system clock.
I decided to set up a pre-backup hook using the "script" line in vzdump.conf. For now the script looks like this:
The reason I didn't use the qemu-guest-agent to run commands is that some of our servers are running outdated OS's for which I didn't manage to install a recent version of qemu-guest-agent. The "pre-stop.sh" script within each VM cleanly shuts down the services in the VM, and if this fails it returns an exit code, cancelling the backup (and triggering proxmox to send an alert email). This seems to work but I end up having to maintain this script with container IDs and corresponding IP addresses.
I am wondering if other proxmox users have suggestions or strategies for safely shutting down services for a backup? Am I potentially being overly cautious about live snapshot backups?
I decided to set up a pre-backup hook using the "script" line in vzdump.conf. For now the script looks like this:
Bash:
#!/bin/bash
log_hook() {
local msg="$1"
echo "$msg"
echo "$(date '+%Y-%m-%d %H:%M:%S') $msg" >> /root/scripts/proxmox_hooks.log
}
if [[ "$1" = "pre-stop" && "$2" == "stop" ]]; then
log_hook "- $*"
case "$3" in
100)
# Container XXX
result=$(ssh root@<server_ip> '/root/scripts/pre-stop.sh')
exit_code=$?
log_hook " $result"
if [ "$exit_code" -ne 0 ]; then
log_hook " pre-stop script failed for XXX"
exit 1
fi
;;
# ... repeat for other containers which get backed up
esac
fi
The reason I didn't use the qemu-guest-agent to run commands is that some of our servers are running outdated OS's for which I didn't manage to install a recent version of qemu-guest-agent. The "pre-stop.sh" script within each VM cleanly shuts down the services in the VM, and if this fails it returns an exit code, cancelling the backup (and triggering proxmox to send an alert email). This seems to work but I end up having to maintain this script with container IDs and corresponding IP addresses.
I am wondering if other proxmox users have suggestions or strategies for safely shutting down services for a backup? Am I potentially being overly cautious about live snapshot backups?