← Knowledge Base
LinuxReference note1 min read · updated 2026-11-27

rsync for copying and simple backups

Copy directories efficiently over SSH, mirror with --delete carefully, and do a dry run first.

rsyncbackupssh
rsync -av src/ dest/                         # archive mode, verbose; the trailing / on src matters
rsync -av -e 'ssh -p 2222' src/ user@host:/data/src/
rsync -avh --progress big.iso user@host:/tmp/
rsync -av --delete --dry-run src/ dest/      # preview a mirror
rsync -av --delete src/ dest/                # make dest identical (removes extra files!)
rsync -av --exclude '.cache' --exclude '*.tmp' src/ dest/

src/ copies the contents of src; src (no slash) copies the directory itself into dest. Always use --dry-run before --delete. rsync is great for copies, but for real backups use a tool with history and encryption (see the restic article).