Database Backup System¶
Automated backup system for MongoDB and MariaDB databases.
Overview¶
| Property | Value |
|---|---|
| Location | python_scripts/database_backups/ |
| Script | backup_script.py |
| Config | config-ME.yaml |
Features¶
- MongoDB backup - Full database dumps
- MariaDB backup - Full database dumps
- S3 upload - Cloud storage
- Retention policies - Automatic cleanup
- Discord notifications - Status webhooks
How It Works¶
graph LR
Cron[Cron Job] --> Script[backup_script.py]
Script --> MongoDB[(MongoDB)]
Script --> MariaDB[(MariaDB)]
Script --> Compress[Compress to .tar.gz]
Compress --> S3[Upload to S3]
Compress --> Local[Local storage]
Script --> Discord[Discord Webhook]
Configuration¶
config-ME.yaml:
mongodb:
host: <host>
databases:
- kaizenmc
- autodonate
mariadb:
host: <host>
databases:
- luckperms
- libertybans
s3:
bucket: <bucket>
retention_days: 30
local:
retention_days: 7
discord:
webhook_url: <url>
Running Backups¶
# Manual run
python backup_script.py
# Via cron (example: daily at 3 AM)
0 3 * * * cd /path/to/database_backups && python backup_script.py
Monitoring¶
- Check Discord webhook channel for backup status
- Failed backups send error notifications
- Check S3 bucket for backup presence