Mirror a folder with rsync (local backup)

Keep a second folder, USB disk, or mount exactly in step with the original — without re-copying everything.

LinuxbackuprsyncMedium risk
Run rsync -avh source/ /destination/ to copy only new and changed files; add --delete to also remove files you deleted from the source.

01Command

Command
$ rsync -avh --delete ~/projects/site/ /mnt/backup/site/

02What it does

rsync compares source and destination and transfers only the differences, making repeat syncs very fast. The trailing slashes matter: source/ copies the contents of source into the destination, while source (no slash) would create a source folder inside it. -a preserves permissions, timestamps, and symlinks.

03Risk

RiskMedium risk
!Warning: --delete makes the destination an exact mirror: files removed from the source are deleted from the backup too. If you delete the wrong things in the source, the backup deletes them on the next run — do a dry run with -n (--dry-run) first to preview.

04Undo

Undo
$ Manually restore deleted extras from the destination backup (no automatic undo)

05Sources

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions