How to Sync Files Efficiently in Linux (rsync)

rsync synchronizes files and directories between locations, transferring only the parts of files that have actually changed.

Published September 30, 2026

rsync synchronises files and directories, copying only the differences, locally or over SSH. It can resume interrupted transfers and delete extras on the destination.

How it works

The common flags are -a (archive: recursive and preserve attributes), -v (verbose), -z (compress) and --delete (remove files missing from the source).

A trailing slash on the source changes behaviour: src/ copies contents, src copies the folder itself.

Try it

rsync -avz src/ user@host:/backup/
sending incremental file list app.js db.js

Practical examples

Local backup

rsync -av /home/ada/ /backup/ada/

Remote sync with deletion

rsync -avz --delete ./site/ user@host:/var/www/site/

Dry run first

rsync -avn --delete src/ dest/

Resume large transfer

rsync -avP big.iso user@host:/tmp/

Common mistakes

  • Missing/adding the trailing slash and nesting folders.
  • Using --delete without a dry run (-n).
  • Forgetting -a so permissions are lost.

Key takeaways

  • rsync copies only changes.
  • Trailing slash matters.
  • Dry run with -n.

FAQ

rsync vs scp?

rsync is incremental and resumable; scp copies everything.

Exclude files?

--exclude='node_modules'.

More Linux articles