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
--deleteremoves 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:dircopies 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
-adoes 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-Aas-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
- Copying files to and from the serverYour first server
- Serving a React/Vite buildHosting a web application with Nginx
- Files, retention and off-site copiesBackups and restores
- Restoring files, and the owners nobody backed upBackups and restores
- What reaches the server: source, artefact or imageDeploying: releases, the switch and rolling back
- Building the artefact: what is left out, and what is fixedDeploying: releases, the switch and rolling back
