Mirror a Directory With rsync --delete

Synchronize a destination so files removed at the source are removed there too.

LinuxbackupFilessyncLow risk
Run rsync -a --delete source/ destination/ to mirror, using --dry-run first.

01Command

Command
$ rsync -a --delete --dry-run source/ destination/

02What it does

--delete turns rsync into a true mirror by removing destination files that no longer exist at the source, which is essential for deploying static sites or syncing a replica. Running with --dry-run first previews exactly what would be removed, a safety habit that suits scheduled jobs.

03Risk

RiskLow risk
Requirementssudo apt install rsync
!Warning: --delete removes data and can wipe the destination if the source is empty or mistyped; always preview and double-check trailing slashes.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Files & Folders

06Related solutions