rsync is a file-copy tool that does two things well: it copies files between local paths or over SSH, and it resumes and synchronizes efficiently. Unlike cp, it only transfers data that has changed, so repeated copies are fast. It has been around for decades, and the current release at the time of writing is 3.5.2 (Nov 2026). It is installed by default on most Linux and macOS systems.
Why rsync beats cp for big copies
rsync uses a delta-transfer algorithm. Instead of re-sending a whole file, it compares the source against what already exists at the destination and transfers only the differences. If you interrupt a large transfer, you can simply re-run the command and it picks up where it left off. That resume behavior alone makes it the default choice for moving and backing up data.
The core flags
Memorize these and you can handle most jobs:
-aarchive: recursive copy preserving permissions, timestamps, symlinks, and other metadata.-vverbose: show what rsync is doing.-zcompress: compress data during transfer, useful over slower networks.-ndry run: show what would happen without changing anything.--dry-runis the long form.--delete: remove files at the destination that no longer exist at the source, so the destination mirrors the source exactly.--exclude: skip files or patterns, for example--exclude='*.tmp'.-P: shorthand for--partial --progress. It keeps partially transferred files and shows progress.-hhuman-readable: format sizes and rates for people.
A safe local copy
To copy a directory locally:
rsync -avh /home/me/projects/webapp/ /backup/webapp/
The trailing slash on the source matters here. webapp/ means "copy the contents of this directory." Without the slash (webapp), rsync copies the directory itself, creating /backup/webapp/webapp. This is the single most common rsync mistake.
Copy over SSH
To push a directory to a remote server:
rsync -avzP /home/me/projects/webapp/ user@server:/var/www/webapp/
rsync treats user@server:path as a remote path over SSH, so this works on any machine where you already have SSH access set up.
Always dry-run first
Before any sync that could change or delete files, run a dry run. It prints exactly what the real command would do, without touching anything:
rsync -avn /home/me/projects/webapp/ /backup/webapp/
Add --delete to the dry run to preview which files would be removed before you commit to destroying them:
rsync -avn --delete /home/me/projects/webapp/ /backup/webapp/
A five-second check is cheaper than restoring a wiped directory. This habit alone prevents most rsync accidents.
The trailing-slash pitfall, one more time
Because it confuses everyone: a trailing slash on the source means "copy the contents," no slash means "copy the directory by name." A slash on the destination makes no difference. Prefer source/ on the source and drop the slash issue entirely by testing with --dry-run first.
Start with -avh and a dry run, and you will rarely go wrong.