first commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# /usr/local/bin/gitea-backup.sh
|
||||
|
||||
BACKUP_DIR="/backup/gitea"
|
||||
DATA_DIR="/home/hans/forgejo/data"
|
||||
CONTAINER_NAME="forgejo" # Dein container_name aus der Compose-Datei
|
||||
RETENTION_DAYS=14
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M)
|
||||
|
||||
echo "[$(date)] Starting Gitea backup..."
|
||||
|
||||
# Backup im Container erstellen
|
||||
docker exec -u git -w /data "$CONTAINER_NAME" \
|
||||
/app/gitea/gitea dump -c /data/gitea/conf/app.ini \
|
||||
--file /data/gitea-dump.zip
|
||||
|
||||
# Vom gemappten Volume ins Backup-Verzeichnis verschieben
|
||||
if [ -f "$DATA_DIR/gitea-dump.zip" ]; then
|
||||
mv "$DATA_DIR/gitea-dump.zip" "$BACKUP_DIR/gitea-dump-$TIMESTAMP.zip"
|
||||
chmod 600 "$BACKUP_DIR/gitea-dump-$TIMESTAMP.zip"
|
||||
|
||||
# Alte Backups entfernen
|
||||
find "$BACKUP_DIR" -name "gitea-dump-*.zip" -mtime +$RETENTION_DAYS -delete
|
||||
|
||||
SIZE=$(du -h "$BACKUP_DIR/gitea-dump-$TIMESTAMP.zip" | cut -f1)
|
||||
echo "[$(date)] Backup completed: gitea-dump-$TIMESTAMP.zip ($SIZE)"
|
||||
else
|
||||
echo "[$(date)] ERROR: Backup file not found!"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user