Stop letting rsync wipe out files when you move to a new backup target

Backup & Recovery (Rsync/Tar/Dd)

Stop letting rsync wipe out files when you move to a new backup target

🧩 The Challenge

You finally spin up that new backup server and run a sync, only to realize you accidentally deleted half your source files because you mixed up your trailing slashes. I’ve been there, and watching years of data vanish in seconds because of a missing character is a nightmare I don’t want you to repeat.

💡 The Fix

Use the –dry-run flag with a dash of –itemize-changes to see exactly what rsync is planning to do before it actually touches your filesystem. It turns a heart-attack-inducing operation into a simple sanity check.

rsync -avun --delete --itemize-changes /source/directory/ /destination/directory/

⚙️ Why It Works

Adding the n flag forces rsync to simulate the transfer without modifying any files, while the itemize-changes output gives you a detailed breakdown of exactly what gets added, deleted, or updated. You get to preview the carnage before you commit.

🚀 Pro-Tip: Always double-check if your source path ends in a slash; trailing slashes tell rsync to copy the contents of the directory, not the directory folder itself.

Linux Tips & Tricks | © ngelinux.com | 9/16/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted