Option to exit backup script without triggering an error

XrXca

Member
May 1, 2021
4
3
8
64
I am coming from a setup where my own custom scripts backed up VM's on a regular basis rotating between backup target servers and keeping X copies, but not doing a backup if the VM hasn't changed since the last backup on the target. I have a number of very large machines that are not run often (development testing, or virtual copies of decommissioned desktops etc.), and the three targets are two NFS servers, and a NAS.

I was looking at the backup hook script to see if I could implement the same type of "only backup if changed" operation using that. I've got it working, the only problem is, whatever value I try for the exit status during the "backup-start" phase, it shows as an error, and the entire job has an error status even though it backs up any changed machines.
In pseudocode the script is:
If ( phase = backup-start ) and ( lastbackup newer than currentmachine ) then exit EXITCODE

Is there any exitcode from the backup script that would abort the current VM backup without triggering an Error? (Basically a skip code, if the exit code is X then skip the current backup without triggering an error)

The excerpt from the log below shows the INFO line generated by my script Backup Skipped (100) and the next line shows the exit code of 25 (which is what I've got EXITCODE set to at the moment), it then goes on to backup the rest of the VM's, but the entire job shows as an error.

I suppose I could simply write my own backup routine, but it would be nice to manage the backups from the GUI,


INFO: starting new backup job: vzdump --mailto ...
INFO: Starting Backup of VM 100 (qemu)
INFO: Backup started at 2021-05-05 05:00:02
INFO: status = stopped
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: VM Name: AlpineTest1
INFO: include disk 'scsi0' 'local-nvme:vm-100-disk-0' 33G
INFO: Backup Skipped (100)
ERROR: Backup of VM 100 failed - command '/usr/local/sbin/backup_hook.sh backup-start stop 100' failed: exit code 25
INFO: Failed at 2021-05-05 05:00:02
INFO: Starting Backup of VM 10001 (qemu)
INFO: Backup started at 2021-05-05 05:00:02
INFO: status = running
INFO: VM Name: AlpineDNS3
INFO: include disk 'scsi0' 'local-lvm:vm-10001-disk-0' 2G
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: creating vzdump archive '/mnt/pve/PVE1_500/dump/vzdump-qemu-10001-2021_05_05-05_00_02.vma.zst'
...
INFO: Backup finished at 2021-05-05 05:04:09
INFO: Backup job finished with errors

TASK ERROR: job errors
 
Hi,
AFAICT there is no good way to do this. Currently, the hook script either fails or works, and it was not designed to work as filter. The hook scripts are called rather late, when the backup task is already prepared and expected to execute.

Feel free to create a feature request on the bug tracker (or even send patches to be discussed to the developer mailing list).
 

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!