Stop rsync from deleting files when the source disk dies

Backup & Recovery (Rsync/Tar/Dd)

Stop rsync from deleting files when the source disk dies

🧩 The Challenge

You’ve set up a nice rsync mirror, but then you accidentally deleted a folder on the source or the drive started throwing I/O errors and emptied out. Next thing you know, rsync dutifully replicates that catastrophe to your backup destination, effectively nuking your only safety net.

💡 The Fix

Use the –existing flag or add a protective file list to your rsync command. It keeps rsync from blowing away files that aren’t present on the source, saving your butt from user error or hardware flakiness.

rsync -av --existing /source/ /destination/

⚙️ Why It Works

Setting this flag tells rsync to only update files that are already there, which prevents it from creating new files on the target or, more importantly, deleting what you didn’t mean to lose.

🚀 Pro-Tip: If you need to keep a full mirror but want a safety buffer, append –backup –backup-dir=/path/to/trash/ instead of just deleting.

Linux Tips & Tricks | © ngelinux.com | 12/1/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted