From f859b776a2bd2830b1a7d7e368f425d2ed6b41e0 Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 2 Feb 2026 15:06:36 +0000 Subject: [PATCH] change -c description --- lxc-backup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lxc-backup.sh b/lxc-backup.sh index 7da906a..8bc7367 100755 --- a/lxc-backup.sh +++ b/lxc-backup.sh @@ -52,7 +52,7 @@ 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 (default: keep all) -h Show this message EOF exit 1 @@ -64,7 +64,7 @@ start_backup() { local compression="$3" local ext=".${compression}" - if [[ "$compression" == 'none' ]]; then + if [[ "$compression" == 'none' ]]; then ext="" else command -v "$compression" >/dev/null 2>&1 || { echo "$compression command not found"; exit 1; } @@ -86,7 +86,7 @@ prune_backups() { local backup_dir="$2" local retention="$3" mapfile -t backup_files < <(find "${backup_dir}/${vm}" -maxdepth 1 -type f -printf '%T@ %p\n' | sort -n | head -n "-${retention}" | cut -d' ' -f2-) - + 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