Compare commits
3
Commits
09a4d6485f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8fe5a19fc | ||
|
|
f859b776a2 | ||
|
|
087983bd4a |
+3
-4
@@ -25,7 +25,6 @@ main() {
|
||||
esac
|
||||
done
|
||||
|
||||
# Helper functions
|
||||
lxc() { command "$cmd" "$@"; }
|
||||
list_vms() { lxc list -c n -f csv; }
|
||||
|
||||
@@ -53,9 +52,8 @@ Options:
|
||||
-d Directory where backups will be stored (default: current directory)
|
||||
-t Manager type: lxc or incus (default: lxc)
|
||||
-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
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
@@ -73,7 +71,6 @@ start_backup() {
|
||||
fi
|
||||
|
||||
local vm_dir="${backup_dir}/${vm}"
|
||||
|
||||
local backup_name
|
||||
backup_name="${vm}_$(date +"%Y-%m-%d_%H-%M-%S").tar${ext}"
|
||||
|
||||
@@ -93,6 +90,8 @@ prune_backups() {
|
||||
if [[ ${#backup_files[@]} -gt 0 ]]; then
|
||||
echo "Removing ${#backup_files[@]} old backup files for $vm (keeping last $retention files)"
|
||||
printf '%s\0' "${backup_files[@]}" | xargs -0 rm -fv > /dev/null
|
||||
elif [[ "${retention}" -eq 0 ]]; then
|
||||
echo "Keeping all existing backups for $vm"
|
||||
else
|
||||
echo "No old backups to remove for $vm"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user