[SOLVED] How to purning backups before archive transfer

monkaX

New Member
Sep 12, 2021
8
1
3
124
Good morning :D

I would like to setup a backup task where the vzdump archive file is pruned before the actual file get transferred to storage

INFO: 100% (15.0 GiB of 15.0 GiB) in 27s, read: 1.2 GiB/s, write: 6.7 MiB/s INFO: backup is sparse: 13.31 GiB (88%) total zero data INFO: transferred 15.00 GiB in 27 seconds (568.9 MiB/s) INFO: archive file size: 743MB INFO: prune older backups with retention: keep-last=1, keep-weekly=1 INFO: removing backup 'usb:backup/vzdump-qemu-100-2021_09_11-09_49_05.vma.zst'

Since the receiving storage has very little space it must delete the previous backup before doing anything else.

I'm not entirely convinced by the global hook script ... don't really wanna test for global conditions

Any recommendations before I go and modify the vzdump crontab ?
 
I have no other choice my backup size is 15G into a usb stick of 16Gb capacity or something along those lines :D

Either way, I solved that problem by using the hook feature of vzdump.

Fortunately the vzdump utility calls the hook scripts with a bunch of parameters such as:

INFO: Hook called: job-start
INFO: Hook called: backup-start snapshot 100
INFO: Hook called: pre-stop snapshot 100
INFO: Hook called: pre-restart snapshot 100
INFO: Hook called: post-restart snapshot 100
etc ...

Code:
# /etc/vzdump.conf
script: /root/bin/hook.sh

Code:
!/bin/bash

path=/mnt/usb-drive/dump
vmid=100

start(){
        [[ $3 == $vmid ]] && rm -f $path/*$vmid*
}

stop(){
        [[ $3 == $vmid ]] && find $path -name "*$vmid*" -mtime -1 -size +100M | xargs ls -lh
}

case "$1" in
    backup-start) start $*;;
    backup-end) stop $*;;
esac
exit 0


Not satisfied with using the VMID as it is too static and can change anytime BUT that will do for now
 
The other way would be to directly modify the /etc/cron.d/vzdump and add the --script to that specific backup job and then hope it doesn't
get auto magically regenerated.

Or modify the vzdump script directly, if you can perl and got time

Don't RIP your backups ;)
 

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!