Hey all,
I’m running Virtualmin on a VPS with 200G disk space with Virtualmin scheduled backups set to one weekly backup on Sunday, and daily Mon-Sat backups with 4 days retention:
Destination Backup contents Description Backup enabled? Level
Local file /backup/%Y-%m-%d_%H-%M_incremental All virtual servers All-accs-incremental Yes, at cron time 0 3 * * 1-6 Incremental
Local file /backup/%Y-%m-%d_%H-%M_FULL All virtual servers All-accs-full Yes, weekly (on Sunday) Full
So far, this schedule has been working pretty well until I archived some old emails which filled up the whole disk during incremental backup generation. Temporary fix was to exclude “*.bak.tar.gz” files in backups.
Having a separate backup partition or remote destination would be a better solution, but for local backups, I was wondering if there is a way to “fool-proof” this by running some sort of a pre-check that would prevent backup from being generated if there isn’t enough space on the disk available.
For example:
- Run a dry run backup or similar to get the estimated backup size
- Compared the given size with current available disk/partition space
- Start the scheduled backup only if there is enough disk space
Or a more simple way, start the backup only if disk use percentage doesn’t exceed the given value.
There is ‘Command to run before backup’ option in Virtualmin >> Backup and Restore >> Scheduled Backups section, could we put an if statement there which would prevent the backup process from continuing?
The command below is an idea to prevent the backup if more than 60% disk is used, besides the obvious last important part:
if [[ $(df -h / | awk '{print $5}' | grep -Eo '[0-9]{1,4}') -gt 60 ]]; then echo "Backup failed - Disk space insufficient" | sendmail admin@example.com; command-to-interrupt-backup; fi
Any advice or ideas are welcome. Thanks!
SYSTEM INFORMATION | |
---|---|
OS type and version | AlmaLinux Linux 8.5 |
Webmin version | 1.990 |
Virtualmin version | 6.17 |