Files
thread-net-git/backup/gitea-backup.sh
T
Claude 0bb44485c1 backup: naechtlicher gitea dump mit Ein-Dump-Rotation
Cron (rantanplan, 03:17): gitea dump -> /opt/backup, nur der neueste
Dump bleibt auf dem Host -- 38G-Platte traegt nicht mehr. Aeltere
Staende off-host ziehen (siehe README/Skriptkopf).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-30 16:21:30 +02:00

21 lines
869 B
Bash
Executable File

#!/bin/sh
# Naechtliches Gitea-Backup (Cron des Users rantanplan, kein sudo noetig).
# Rotation: Es bleibt NUR der neueste Dump auf dem Host -- die Platte (38G)
# traegt nicht mehr, aeltere Staende gehoeren off-host:
# scp -P 2248 rantanplan@188.245.193.243:/opt/backup/gitea-dump-<datum>.zip .
set -eu
BACKUP_DIR=/opt/backup
CONTAINER=thread-net-git-gitea-1
TARGET="$BACKUP_DIR/gitea-dump-$(date +%F).zip"
docker exec "$CONTAINER" rm -f /tmp/gitea-dump.zip
docker exec -u git -w /tmp "$CONTAINER" gitea dump -c /data/gitea/conf/app.ini -f /tmp/gitea-dump.zip
docker cp -q "$CONTAINER:/tmp/gitea-dump.zip" "$TARGET.tmp"
docker exec "$CONTAINER" rm -f /tmp/gitea-dump.zip
mv "$TARGET.tmp" "$TARGET"
find "$BACKUP_DIR" -maxdepth 1 -name 'gitea-dump-*.zip' ! -name "$(basename "$TARGET")" -delete
echo "$(date -Is) backup ok: $TARGET ($(du -h "$TARGET" | cut -f1))"