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") NOW=$(date +"%Y%m%d-%H%M")
OUT="/backup/output/gitea-$NOW.tar.gz" OUT="/backup/output/gitea-$NOW.tar.gz"
KEEP_FILES=${KEEP_FILES:-4}
echo "== Gitea SQLite Backup $NOW ==" echo "== Gitea SQLite Backup $NOW =="
tar -czvf "$OUT" /data/gitea tar -czvf "$OUT" /data/gitea
echo "Backup saved as $OUT" 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."

View File

@@ -18,6 +18,8 @@ services:
backup: backup:
image: alpine:latest image: alpine:latest
container_name: gitea-backup container_name: gitea-backup
environment:
- KEEP_FILES=7
volumes: volumes:
- ./data:/data:ro - ./data:/data:ro
- ./backup:/backup - ./backup:/backup