In modern production environments, database availability and disaster recovery are critical. A single-server backup is often insufficient due to hardware failure, ransomware attacks, or accidental deletion.
This guide demonstrates how to implement automated incremental backups across multiple servers, with:
Remote replication for redundancy
Incremental backups for storage efficiency
Real-time alerting via email or Slack
Enterprise-grade monitoring
This setup is ideal for production MySQL, MariaDB, or PostgreSQL databases across multiple servers or data centers.
Scenario:
A SaaS company hosts databases in three regions.
Daily full backups are time-consuming and consume massive storage.
They need incremental backups stored both locally and remotely for high availability.
Admins need instant alerts if backups fail.
Solution: Multi-server incremental backups with remote replication and alerting.
Linux servers with MySQL/MariaDB/PostgreSQL
Root or sudo access
rsync, ssh, cron, and mail installed
Optional: Slack webhook for notifications
SSH key-based authentication between servers
Generate SSH key on primary backup server:
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa_backup -N ""
Copy key to remote backup server:
ssh-copy-id -i ~/.ssh/id_rsa_backup user@remote-backup-server
Why: Allows automated backups via cron without manual password entry.
Local backup directories:
mkdir -p /backup/db/full
mkdir -p /backup/db/incremental
Remote backup directories:
ssh user@remote-backup-server "mkdir -p /remote-backups/db/full /remote-backups/db/incremental"
Create /usr/local/bin/multi_server_db_backup.sh:
#!/bin/bash
# Database credentials
DB_USER="root"
DB_PASS="YourStrongPassword"
# Directories
LOCAL_FULL="/backup/db/full"
LOCAL_INC="/backup/db/incremental"
REMOTE_USER="user"
REMOTE_HOST="remote-backup-server"
REMOTE_DIR="/remote-backups/db"
DATE=$(date +%F_%H-%M)
# Step 1: Full backup weekly (Sunday)
DAY=$(date +%u)
if [ "$DAY" -eq 7 ]; then
mysqldump -u $DB_USER -p$DB_PASS --all-databases > $LOCAL_FULL/db_full_$DATE.sql
rsync -avz $LOCAL_FULL/db_full_$DATE.sql $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/full/
else
# Incremental backup
mkdir -p $LOCAL_INC/$DATE
rsync -av --link-dest=$LOCAL_FULL $LOCAL_FULL/ $LOCAL_INC/$DATE/
rsync -avz $LOCAL_INC/$DATE/ $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/incremental/$DATE/
fi
# Step 2: Alert if backup fails
if [ $? -ne 0 ]; then
echo "Backup failed on $(hostname) at $(date)" | mail -s "Backup Failure Alert" [email protected]
fi
Make it executable:
chmod +x /usr/local/bin/multi_server_db_backup.sh
Explanation:
Weekly full backups → Local + remote
Daily incremental backups → Only changed files, linked to last full backup
Rsync ensures remote replication
Email alerts on failure
Edit cron:
crontab -e
Add:
# Run backup daily at 2 AM
0 2 * * * /usr/local/bin/multi_server_db_backup.sh
Add Slack alert function:
send_slack_alert() {
WEBHOOK="https://hooks.slack.com/services/XXXX/XXXX/XXXX"
MESSAGE="$1"
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$MESSAGE\"}" $WEBHOOK
}
Call after backup failure:
send_slack_alert "Backup failed on $(hostname) at $(date)"
Automatically remove backups older than 30 days:
find /backup/db/full -type f -mtime +30 -delete
find /backup/db/incremental -type d -mtime +30 -exec rm -rf {} \;
ssh user@remote-backup-server "find /remote-backups/db/full -type f -mtime +30 -delete"
ssh user@remote-backup-server "find /remote-backups/db/incremental -type d -mtime +30 -exec rm -rf {} \;"
Sunday → Full backup locally + remote
Monday–Saturday → Incremental backup locally + remote
Rsync ensures synchronized copies across servers
Cron runs daily → backups automated
Admin receives alerts if backup fails
Older backups deleted automatically → efficient storage usage
Restore latest full backup from local or remote:
mysql -u root -p < /backup/db/full/db_full_2026-01-28.sql
Apply incremental backups in order to reach latest state:
mysql -u root -p < /backup/db/incremental/2026-01-29/db_full_2026-01-28.sql
Remote backups ensure disaster recovery if local server fails.
Test restores regularly
Encrypt backups if storing remotely:
gpg -c /backup/db/full/db_full_2026-01-28.sql
Use dedicated backup users for SSH and database
Monitor disk space on both local and remote servers
Log all backup activity for auditing
Multi-server redundancy → protects against hardware or site failure
Incremental backups save storage and bandwidth
Automated alerts keep admins informed
Cron + rsync ensures consistent, reliable backups
Production-ready solution for large-scale environments
💡 Pro Tip: Integrate with object storage (S3, GCS, Azure Blob) for cloud-based redundancy. Combine with monitoring tools like Prometheus for proactive backup health alerts.