gitea-backup-pull: switch vlda-01 retention from a fixed count to a 30-day rotation

KEEP=30 (last 30 archives) approximated 30 days only if there was
exactly one dump per day. Prune by file mtime instead (find -mtime +30)
so a catch-up burst after time offline doesn't prematurely evict
recent dumps, and a quiet stretch doesn't hoard month-old ones.
This commit is contained in:
2026-07-26 20:30:02 +02:00
parent 45856f48f8
commit 2b86579fb8
3 changed files with 20 additions and 8 deletions
@@ -28,7 +28,7 @@ REMOTE_PORT=10022
UD_LABEL=WSD2L840
UD_MOUNTPOINT=/mnt/disks/WSD2L840
LOCAL_DIR="$UD_MOUNTPOINT/git"
KEEP=30
KEEP_DAYS=30
# WSD2L840 is an Unassigned Device, not part of the array - not
# guaranteed to already be mounted when this runs. Resolve by label
@@ -150,11 +150,17 @@ if [ -s "$DEL_BATCH" ]; then
fi
fi
# prune to the last $KEEP archives (vlda-01 has far more headroom than
# alpha, so this is the real long-term history now that alpha deletes
# its own copies right after a verified pull)
# prune anything older than $KEEP_DAYS calendar days (vlda-01 has far
# more headroom than alpha, so this is the real long-term history now
# that alpha deletes its own copies right after a verified pull). A
# calendar-day window rather than a fixed count on purpose: a burst of
# catch-up pulls after being offline a while shouldn't prematurely evict
# genuinely recent dumps just because there are suddenly more than a
# fixed count, and a quiet stretch with few new dumps shouldn't keep
# month-old ones around just because too few newer ones have arrived to
# push them out.
cd "$LOCAL_DIR" || exit 1
ls -1t gitea-dump-*.zip 2>/dev/null | tail -n +$((KEEP + 1)) | while read -r old; do
find . -maxdepth 1 -name 'gitea-dump-*.zip' -mtime +"$KEEP_DAYS" -print0 | while IFS= read -r -d '' old; do
rm -f "$old" "${old}.sha256"
done