Server Management
Automated Database Backups
Why Automated Backups Matter
A corrupted database or accidental deletion can wipe out your entire subscriber list and campaign history. Automated daily backups take minutes to set up and can save hours of recovery work.
The Backup Script
Create /home/vbrand/scripts/backup-db.sh:
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/home/vbrand/backups/db"
DB_NAME="acellemail"
DB_USER="vbrand"
DB_PASS="yourpassword"
KEEP_DAYS=14
mkdir -p "\$BACKUP_DIR"
mysqldump -u"\$DB_USER" -p"\$DB_PASS" "\$DB_NAME" \
--single-transaction --quick --lock-tables=false \
| gzip > "\$BACKUP_DIR/\$DB_NAME_\$DATE.sql.gz"
# Remove backups older than KEEP_DAYS
find "\$BACKUP_DIR" -name "*.sql.gz" -mtime +\$KEEP_DAYS -delete
echo "Backup complete: \$BACKUP_DIR/\$DB_NAME_\$DATE.sql.gz"
chmod +x /home/vbrand/scripts/backup-db.sh
Schedule with Cron
crontab -e
Add:
0 2 * * * /home/vbrand/scripts/backup-db.sh >> /home/vbrand/logs/backup.log 2>&1
This runs at 2:00 AM daily.
Offsite Backup
For safety, copy backups to an S3 bucket:
aws s3 sync /home/vbrand/backups/db s3://your-bucket/acellemail-backups/
Restoring from Backup
gunzip < /home/vbrand/backups/db/acellemail_20260301_020000.sql.gz \
| mysql -uvbrand -p acellemail