Keep your rsync backups truly in sync
Backup & Recovery (Rsync/Tar/Dd)
Keep your rsync backups truly in sync
🧩 The Challenge
You’ve got your rsync backup job humming along, dutifully copying files. Problem is, your destination disk just keeps growing. You prune old projects, clean out downloads, delete temporary files from your source, but your backup drive never seems to get the memo. Go to restore something important, and you might find old, deleted files still lurking there. Your backup isn’t a mirror; it’s a hoarder.
💡 The Fix
There’s a simple flag to add to your rsync command that tells it to actually remove files from the destination if they’re no longer on the source. This keeps your backups accurate and prevents that backup drive from needlessly swelling up over time.
rsync -avh --delete --stats /path/to/source/ /path/to/destination/
⚙️ Why It Works
Adding `–delete` tells rsync to remove files from the receiver (destination) that aren’t present on the sender (source). And that trailing slash on `/path/to/source/`? That’s critical; it copies the *contents* of the source directory, not the directory itself.
🚀 Pro-Tip: First time using `–delete` on a critical path? Always, *always* run it with `–dry-run` first. Don’t learn this the hard way.
Linux Tips & Tricks | © ngelinux.com | 10/27/2026
