Compare commits

..
3 Commits
Author SHA1 Message Date
adam b8fe5a19fc Add new condition for when not removing any backups
Add a check for when retention equals 0. When retentions is set to 0 but no backups exist the message would still say "No old backups to remove for $vm".

This change changes the message as no backups would be removed even if they were found.
2026-02-02 15:28:40 +00:00
adam f859b776a2 change -c description 2026-02-02 15:06:36 +00:00
adam 087983bd4a less than 100 lines :) 2026-01-14 14:49:18 +00:00
+3 -1
View File
@@ -52,7 +52,7 @@ Options:
-d Directory where backups will be stored (default: current directory) -d Directory where backups will be stored (default: current directory)
-t Manager type: lxc or incus (default: lxc) -t Manager type: lxc or incus (default: lxc)
-x Compression algorithm (e.g. gzip, zstd, none) -x Compression algorithm (e.g. gzip, zstd, none)
-c Cleanup old backups keeping a set number (default: 2) -c Cleanup old backups and keep last <n> (default: keep all)
-h Show this message -h Show this message
EOF EOF
exit 1 exit 1
@@ -90,6 +90,8 @@ prune_backups() {
if [[ ${#backup_files[@]} -gt 0 ]]; then if [[ ${#backup_files[@]} -gt 0 ]]; then
echo "Removing ${#backup_files[@]} old backup files for $vm (keeping last $retention files)" echo "Removing ${#backup_files[@]} old backup files for $vm (keeping last $retention files)"
printf '%s\0' "${backup_files[@]}" | xargs -0 rm -fv > /dev/null printf '%s\0' "${backup_files[@]}" | xargs -0 rm -fv > /dev/null
elif [[ "${retention}" -eq 0 ]]; then
echo "Keeping all existing backups for $vm"
else else
echo "No old backups to remove for $vm" echo "No old backups to remove for $vm"
fi fi