backup: Dump als Stream mit Runner-Stopp und Retries, README nachziehen

Script-Ueberarbeitung aus dem Live-Betrieb nachcommittet: Runner-Stopp
gegen das SQLite-Journal-Race, Dump als Stream (tar.gz statt zip),
3 Versuche mit Retry. README dokumentiert das neue Verfahren und den
aktuellen Pausen-Zustand des Crons (Backlogs CFGMON-09).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-07-30 18:16:17 +02:00
parent 0bb44485c1
commit 02b32248b7
2 changed files with 32 additions and 15 deletions
+11 -9
View File
@@ -67,14 +67,16 @@ Cloud-Firewall, ohne die Zertifikatsprüfung zu brechen.
## Backup & Restore ## Backup & Restore
Warm-Backup (laufender Betrieb, nächtlich per Cron des Users `rantanplan`): Warm-Backup: nächtlich um 03:17 per Cron des Users `rantanplan`
(`backup/gitea-backup.sh`, Log: `/opt/backup/backup.log`).
```bash **Derzeit pausiert** (Cron auskommentiert, seit 2026-07-30): die Backups
docker exec -u git -w /tmp thread-net-git-gitea-1 \ sollen off-host in ein Borg-Repo auf einer Storage Box, bis dahin bleibt
gitea dump -c /data/gitea/conf/app.ini -f /tmp/gitea-dump.zip der letzte Dump vom 2026-07-30 liegen — siehe CFGMON-09 im Repo
docker cp thread-net-git-gitea-1:/tmp/gitea-dump.zip /opt/backup/gitea-dump-$(date +%F).zip `sorb/Backlogs`. Das Skript
docker exec thread-net-git-gitea-1 rm /tmp/gitea-dump.zip stoppt kurz den Runner (SQLite-Journal-Race bei `gitea dump`), streamt
``` den Dump ohne Zwischenkopie (`gitea dump --type tar -f - | gzip`) und
behält **nur den neuesten Stand** auf dem Host — die 38-G-Platte trägt
nicht mehr. Manuell: einfach das Skript ausführen.
Restore auf frischem Host: Volume `thread-net-git_gitea-data` anlegen, Restore auf frischem Host: Volume `thread-net-git_gitea-data` anlegen,
Dump-Zip entpacken (`gitea-repo.zip``/data/git/repositories`, Dump-Zip entpacken (`gitea-repo.zip``/data/git/repositories`,
@@ -84,7 +86,7 @@ https://docs.gitea.com/administration/backup-and-restore
**Off-Host-Kopie nicht vergessen** — ein Backup auf demselben Host schützt **Off-Host-Kopie nicht vergessen** — ein Backup auf demselben Host schützt
nicht vor Plattenverlust: nicht vor Plattenverlust:
`scp -P 2248 rantanplan@188.245.193.243:/opt/backup/gitea-dump-<datum>.zip .` `scp -P 2248 rantanplan@188.245.193.243:/opt/backup/gitea-dump-<datum>.tar.gz .`
## Bezüge ## Bezüge
+21 -6
View File
@@ -7,14 +7,29 @@ set -eu
BACKUP_DIR=/opt/backup BACKUP_DIR=/opt/backup
CONTAINER=thread-net-git-gitea-1 CONTAINER=thread-net-git-gitea-1
TARGET="$BACKUP_DIR/gitea-dump-$(date +%F).zip" TARGET="$BACKUP_DIR/gitea-dump-$(date +%F).tar.gz"
docker exec "$CONTAINER" rm -f /tmp/gitea-dump.zip # Runner pausieren: sein DB-Polling erzeugt sekuendlich SQLite-Journal-
docker exec -u git -w /tmp "$CONTAINER" gitea dump -c /data/gitea/conf/app.ini -f /tmp/gitea-dump.zip # Dateien, an deren Verschwinden "gitea dump" beim Packen scheitert
docker cp -q "$CONTAINER:/tmp/gitea-dump.zip" "$TARGET.tmp" # (stat gitea.db-journal: no such file). Start am Ende auch im Fehlerfall.
docker exec "$CONTAINER" rm -f /tmp/gitea-dump.zip docker stop gitea-runner >/dev/null
trap 'docker start gitea-runner >/dev/null' EXIT
# Dump als Stream (-f -): keine Zwischendatei im Container -- die Platte
# traegt nur EINE Dump-Kopie plus den alten Stand waehrend der Rotation.
ok=""
for attempt in 1 2 3; do
if docker exec -u git -w /tmp "$CONTAINER" gitea dump -c /data/gitea/conf/app.ini --type tar -f - 2>>"$BACKUP_DIR/backup.log" | gzip > "$TARGET.tmp"; then
ok=1
break
fi
rm -f "$TARGET.tmp"
echo "$(date -Is) dump-Versuch $attempt fehlgeschlagen, retry..."
sleep 5
done
[ -n "$ok" ] || { echo "$(date -Is) backup FEHLGESCHLAGEN nach 3 Versuchen"; exit 1; }
mv "$TARGET.tmp" "$TARGET" mv "$TARGET.tmp" "$TARGET"
find "$BACKUP_DIR" -maxdepth 1 -name 'gitea-dump-*.zip' ! -name "$(basename "$TARGET")" -delete find "$BACKUP_DIR" -maxdepth 1 -name 'gitea-dump-*' ! -name "$(basename "$TARGET")" -delete
echo "$(date -Is) backup ok: $TARGET ($(du -h "$TARGET" | cut -f1))" echo "$(date -Is) backup ok: $TARGET ($(du -h "$TARGET" | cut -f1))"