Skip to main content
Kill -9 Club
Sign in

rsync

Transfer and archivesPackage: rsyncHandle with care

Synchronises two trees by transferring only the differences, locally or over SSH. -a keeps permissions, dates and links; -n rehearses without writing, and that is where to start.

A mistake with this command can destroy data or lock you out

  • --delete removes at the destination whatever no longer exists at the source, so an empty or misspelled source empties the destination. And the trailing / changes the meaning: dir copies the directory, dir/ copies its contents.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

rsync -a
Archive mode: recursive, preserving permissions, ownership, timestamps and symbolic links. What separates a copy from a *faithful* copy.
rsync -v
Lists the files transferred.
rsync -z
Compresses data during transfer: useful over a slow link, pointless locally.
rsync -e
Chooses the remote shell, for example -e "ssh -p 2222" for a non-standard SSH port.
rsync -A
Preserves ACLs, which -a does not copy. Needed on both sides, backup and restore, or the tree comes back with real access that differs from its apparent permissions.
rsync -X
Preserves extended attributes, also missing from -a. Combines with -A as -aAX.
rsync --numeric-ids
Keeps numeric owner and group ids instead of mapping them by name. Use it when the destination does not share the same accounts, so a UID is not replaced by the wrong name.
rsync --delete
Deletes at the destination whatever no longer exists at the source. What makes a true mirror — and what makes a wrong source path destructive.
rsync --dry-run
Simulates the transfer without writing anything. Always run it before a --delete.

Lessons that teach it