Prune legacy zstd archive names

This commit is contained in:
Codex authored and zorruno committed 2026-09-21 11:52:31 +12:00
1 parent e27387bd93
commit 1bddfe2b3d
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -11,7 +11,8 @@ logic remains common and can be updated through Git.
1. `stages/10-containers.sh` — stop, archive, pull, start and verify projects.
2. `methods/20-rclone.sh` — copy archives to an rclone destination when enabled.
3. `methods/30-smb.sh` — copy archives to a mounted SMB share when enabled.
4. `stages/90-prune.sh` — retain the newest configured number locally.
4. `stages/90-prune.sh` — retain the newest configured number of `.zst`
archives locally, including legacy `.zst` and current `.tar.zst` names.
Every stage can also be run directly. The old `docker-backup.sh` name invokes
the container archive stage, while `dockerbackup_prune.sh` invokes the local
+2 -1
View File
@@ -16,7 +16,8 @@ done
require_positive_integer KEEP_COUNT "$KEEP_COUNT"
[[ -d "$BACKUP_ROOT" ]] || { log SKIP "Backup root does not exist: $BACKUP_ROOT"; exit 0; }
while IFS= read -r -d '' dir; do
mapfile -d '' -t files < <(find "$dir" -maxdepth 1 -type f -name '*.tar.zst' -printf '%T@ %p\0' | sort -z -nr | cut -z -d' ' -f2-)
# Match both current *.tar.zst archives and legacy *.zst archives.
mapfile -d '' -t files < <(find "$dir" -maxdepth 1 -type f -name '*.zst' -printf '%T@ %p\0' | sort -z -nr | cut -z -d' ' -f2-)
(( ${#files[@]} > KEEP_COUNT )) || continue
for file in "${files[@]:KEEP_COUNT}"; do
if (( DRY_RUN )); then log WOULD "Remove $file"; else rm -f -- "$file"; log DELETE "Removed $file"; fi