add backup retention and cinfigure 7 days in compose

This commit is contained in:
2026-03-13 12:45:44 +01:00
parent 555f8ea7ff
commit ffe2d10c62
2 changed files with 7 additions and 0 deletions

View File

@@ -4,9 +4,14 @@ set -e
NOW=$(date +"%Y%m%d-%H%M")
OUT="/backup/output/gitea-$NOW.tar.gz"
KEEP_FILES=${KEEP_FILES:-4}
echo "== Gitea SQLite Backup $NOW =="
tar -czvf "$OUT" /data/gitea
echo "Backup saved as $OUT"
echo "== Cleanup: keeping last $KEEP_FILES backups =="
ls -1t /backup/output/gitea-*.tar.gz 2>/dev/null | tail -n +$((KEEP_FILES + 1)) | xargs -r rm -f
#echo "Cleanup done."