Dangerous Commands
Run Rsync Without Deleting Your Backup
You need to preview an rsync operation before moving or deleting files.
Command
rsync -avhn --delete ./source/ ./backup/
What changed
The dry run prints intended changes without modifying files.
Danger
caution
When to use it
Use this before any sync involving deletes, production data, or backups.
When not to use it
Do not assume dry-run output is safe if the source and destination paths are reversed.
Undo or recovery
No state is changed during the dry run. If you remove `-n`, make a backup first.
Expected output
A list of files that would be copied, updated, or deleted.
demo script
Disposable terminal steps
find source backup -maxdepth 2 -type f | sortrsync -avhn --delete ./source/ ./backup/rsync -avh --delete ./source/ ./backup/
simulated output
What it looks like
::fixture-ready::
$ find source backup -maxdepth 2 -type f | sort
backup/app.conf
backup/stale.txt
source/app.conf
source/index.html
::exit-code::0
$ rsync -avhn --delete ./source/ ./backup/
sending incremental file list
deleting stale.txt
app.conf
index.html
sent 101 bytes received 31 bytes 264.00 bytes/sec
total size is 24 speedup is 0.18 (DRY RUN)
::exit-code::0
$ rsync -avh --delete ./source/ ./backup/
sending incremental file list
deleting stale.txt
app.conf
index.html
sent 209 bytes received 67 bytes 552.00 bytes/sec
total size is 24 speedup is 0.09
::exit-code::0
YouTube Short
Preview rsync before it bites.
The `-n` flag is the pause button. It shows what rsync would do before you let it touch the files.
LinkedIn hook
One rsync flag can save you. Another can erase the wrong side.
Question: Have you ever seen `rsync --delete` pointed the wrong way?
experiments
A/B tests to run
Metric: youtube_retention_15s
A: One rsync flag can save you. Another can erase the wrong side.
B: Run this before `rsync --delete`.