Dangerous Commands
Dry run / previewPreview What Rsync Would Delete
You need to know which files rsync would delete before running a real sync.
Command
rsync -avhn --delete ./source/ ./backup/ | grep '^deleting'
Before you run this
System impact: Preview only. Still verify source and destination paths before running the real command.
When not to use it: Do not remove `-n` until paths and direction are confirmed.
Expected output
Lines showing files that would be deleted.
System impact
Dry run / preview. Nothing changes because `-n` performs a dry run.
When to use it
Use this before allowing rsync to delete anything.
When not to use it
Do not remove `-n` until paths and direction are confirmed.
Recovery / rollback
No state is changed during the dry run.
next steps
Related commands
Run Rsync Without Deleting Your Backup
One rsync flag can save you. Another can erase the wrong side.
rsync -avhn --delete ./source/ ./backup/
Preview Backup Drift with rsync
Rsync can tell you what would change before it changes anything.
rsync -ain --delete source/ backup/
Print a Dry-Run Removal Script
The reviewable cleanup command is the one you print before you run.
find /var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n' 2>/dev/null
Inspect Permissions Before Changing Them
The permission fix was easy. Knowing what not to chmod was the hard part.
namei -l /var/www/example/index.html
Compare Source and Backup File Lists
A backup can be missing files and still look plausible at a glance.
comm -3 <(find source -type f | sed 's#^source/##' | sort) <(find backup -type f | sed 's#^backup/##' | sort)
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.