Back to commands

Dangerous Commands

Dry run / preview

Run Rsync Without Deleting Your Backup

You need to preview an rsync operation before moving or deleting files.

Command

rsync -avhn --delete ./source/ ./backup/

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 assume dry-run output is safe if the source and destination paths are reversed.

Expected output

A list of files that would be copied, updated, or deleted.

System impact

Dry run / preview. The dry run prints intended changes without modifying files.

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.

Recovery / rollback

No state is changed during the dry run. If you remove `-n`, make a backup first.

next steps

Related commands

Dangerous Commands Dry run

Preview What Rsync Would Delete

`rsync --delete` is useful. It is also how people erase the wrong side.

rsync -avhn --delete ./source/ ./backup/ | grep '^deleting'
Hosting Operations Dry run

Preview Backup Drift with rsync

Rsync can tell you what would change before it changes anything.

rsync -ain --delete source/ backup/
Dangerous Commands Deletes data

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
Hosting Operations Can be slow

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.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.