# Remote Sync (Rsync) Rsync is a Unix utility for fast, incremental file synchronization between two locations ; local-to-local, local-to-remote, or between two paths on the same remote. It was first released in 1996 by Andrew Tridgell and Paul Mackerras, and has remained the default tool for "copy these files, but only what changed." Its differentiating idea is the **rsync algorithm**: when transferring a changed file, the receiver computes rolling checksums over fixed-size blocks of its existing copy, the sender uses those to figure out which blocks already match, and only the *delta* travels over the wire. Combined with compression, this makes rsync dramatically faster than naïve copy-everything tools for large, slowly changing datasets. ## Why It Still Matters Despite being almost three decades old, rsync remains the workhorse for backups, mirror builds, deployment pipelines, and any system that needs to keep two trees in sync without a full transfer. Modern AI tooling has rediscovered it: [[Crabbox]] uses rsync to push the developer's *dirty checkout* to a leased remote test runner, so AI agents can run tests on cloud machines without going through commit/push/CI. ## Common Patterns ### Local backup ```bash rsync -avh --delete /source/ /backup/ ``` - `-a` archive (recursive, preserve permissions, times, symlinks) - `-v` verbose - `-h` human-readable sizes - `--delete` remove files in destination that no longer exist in source ### Push to remote over SSH ```bash rsync -avzh --progress ./project/ user@host:/srv/project/ ``` - `-z` compress in transit (worth it on slow links, sometimes a loss on fast LANs) - `--progress` per-file progress - Trailing slash on `./project/` means "contents of project," not "the project directory itself" ; this is the most common rsync footgun ### Resumable, partial transfers ```bash rsync -avzh --partial --append-verify big-file.iso user@host:/data/ ``` ### Dry run (always test first when using --delete) ```bash rsync -avhn --delete /source/ /backup/ ``` ## rsync vs Alternatives - **vs `cp`**: rsync sends only deltas, preserves more metadata, works over the network - **vs `scp`**: rsync resumes, transfers only changes, has `--exclude` ; OpenSSH considers `scp` deprecated, see [[Secure Copy Protocol (SCP)]] - **vs `sftp`**: SFTP is interactive and protocol-level; rsync is a bulk-sync engine on top of SSH or its own daemon - **vs `git`**: git is content-addressed and meant for source code; rsync is a generic file mover with no commit graph - **vs object storage tools (`aws s3 sync`, `rclone`)**: rsync targets POSIX filesystems ; for object stores use the native tool ## Transport Modes - **rsync over SSH** (most common): wraps file transfer in [[Secure Shell (SSH)]] - **rsync daemon**: runs as a service on port 873, useful for public mirrors and unauthenticated read-only access - **Local mode**: source and destination both on the same machine ; still benefits from the algorithm for large files ## References - Project home: https://rsync.samba.org/ - Manpage: https://download.samba.org/pub/rsync/rsync.1 - The original tech report (Tridgell & Mackerras): https://rsync.samba.org/tech_report/ ## Related - [[Secure Shell (SSH)]] - [[Secure Copy Protocol (SCP)]] - [[Linux]] - [[Crabbox]]