rsync command
Sync files and directories locally or over SSH, copying only what changed.
- Downloads & file transfer
- Package rsync
- 8 options · 9 examples
Syntax
rsync [options] source destinationProvided by the rsync package. Run man rsync for the full manual.
Common options
| Option | What it does |
|---|---|
-a | Archive: recursive, keep permissions, times, links |
-v | Verbose |
-z | Compress during transfer |
-P | Show progress and keep partial files |
-n | Dry run: show what would happen |
--delete | Delete files in the destination that are gone from the source |
--exclude=PATTERN | Skip matching files |
-e "ssh -p N" | Use SSH on another port |
Examples
Copy a directory locally
rsync -a /var/www/ /backup/www/Copy to a server
rsync -avz site/ user@server:/var/www/site/Download from a server
rsync -avz user@server:/var/backups/ ./backups/Mirror exactly (deletes extras)
rsync -a --delete src/ dest/Preview first
rsync -avn --delete src/ dest/Show progress, resume big files
rsync -aP bigfile.iso user@server:~Exclude files
rsync -av --exclude="node_modules" --exclude="*.log" app/ backup/Use another SSH port
rsync -av -e "ssh -p 2222" data/ user@server:/data/Only copy files missing at the destination
rsync -av --ignore-existing src/ dest/
No example matches. Check the options table or search the guides.
Tips
- A trailing slash matters:
src/copies the contents,srccopies the directory itself.
rsync guides
- Rsync Command to Copy Missing Files (Examples) Linux Commands · Updated Apr 2025
- Rsync Command in Linux With 12 Practical Examples Linux Commands · Updated Apr 2025
- Rsync Over a Non-Standard SSH Port: A Beginner’s Guide Linux Commands · Updated Apr 2025
- Rsync Command to Exclude Files and Directories: An Ultimate Guide Linux Commands · Updated Apr 2025
- Backing Up Your Linux System with Rsync: A Step-by-Step Guide Linux Commands · Updated Apr 2026
- Using Rsync for Effective Data Backup: A Step-by-step Guide Linux Commands · Updated Apr 2025
