Mirror a Directory With rsync --delete
Synchronize a destination so files removed at the source are removed there too.
01Command
$ 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- rsync.1.en.html manual page (Debian bookworm)Evidence: Documents the --delete option and its interaction with dry runs.
Last verified: 2026-10-13 · Category: Files & Folders
06Related solutions
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
rsync copies over SSH, skips unchanged files, resumes interrupted transfers, and preserves permissions and timestamps.