Why Incremental Backups?
Full backups transfer all data every time. Incremental backups only transfer files that changed since the last backup, saving time and bandwidth significantly.
Basic rsync Backup
rsync -avz --delete /var/www/ /backups/www/Key flags:
-a— archive mode (preserves permissions, ownership, timestamps)-v— verbose output-z— compress during transfer--delete— remove files from destination that no longer exist in source
Hard-Link Incremental Backups
This technique creates daily snapshots that look like full backups but only use disk space for changed files:
#!/bin/bash
SOURCE="/var/www"
DEST="/backups/snapshots"
DATE=$(date +%Y-%m-%d)
LATEST="$DEST/latest"
rsync -av --delete --link-dest="$LATEST" "$SOURCE/" "$DEST/$DATE/"
rm -f "$LATEST"
ln -s "$DEST/$DATE" "$LATEST"
# Keep 30 days
find "$DEST" -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \;The --link-dest option creates hard links to unchanged files from the previous backup, so each snapshot appears complete but only new/changed files consume additional disk space.
Remote Incremental Backups
rsync -avz -e "ssh -p 22 -i /root/.ssh/backup_key" --link-dest=/backups/latest /var/www/ user@backup-server:/backups/$(date +%Y-%m-%d)/Bandwidth Limiting
# Limit to 10 MB/s
rsync -avz --bwlimit=10000 /source/ /dest/Exclude Patterns
rsync -avz --exclude='*.log' --exclude='/cache/' --exclude='/tmp/' /var/www/ /backups/www/