docker compose yml and backup script done by crone

This commit is contained in:
root
2026-04-12 14:06:19 +00:00
parent adf4f4d12b
commit 052b2237a6
2 changed files with 80 additions and 0 deletions

19
backup.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
DATE=$(date +%F-%H-%M)
BACKUP_DIR="/root/gitea/backups"
SOURCE_DIR="/root/gitea"
# Create temp SQL dump
docker exec gitea-db mysqldump -u root -prootstrongpassword gitea > $BACKUP_DIR/db-$DATE.sql
# Create full backup archive
tar czf $BACKUP_DIR/gitea-backup-$DATE.tar.gz \
-C $SOURCE_DIR \
gitea mariadb
# Optional: remove SQL dump after packing (keeps archive clean)
rm $BACKUP_DIR/db-$DATE.sql
# Cleanup old backups (keep last 7 days)
find $BACKUP_DIR -type f -mtime +7 -delete