rsync Cheatsheet
By Dejan Panovski
•Updated on
•
Download PDF
Quick reference for rsync commands and options
Rsync is a fast file sync tool for local and remote transfers. This cheatsheet covers the most common rsync commands, options, and patterns.
Install #
| Command | Description |
|---|
sudo apt install rsync | Install on Debian/Ubuntu |
sudo yum install rsync | Install on RHEL/CentOS |
sudo dnf install rsync | Install on Fedora |
Basic Syntax #
| Command | Description |
|---|
rsync [OPTION] SRC DEST | Local sync |
rsync [OPTION] SRC USER@HOST:DEST | Local → remote |
rsync [OPTION] USER@HOST:SRC DEST | Remote → local |
Local Sync Examples #
| Command | Description |
|---|
rsync -a src/ dest/ | Mirror contents |
rsync -a src dest/ | Copy dir into dest |
rsync -av src/ dest/ | Verbose sync |
rsync -a --delete src/ dest/ | Delete extra files |
Remote over SSH #
| Command | Description |
|---|
rsync -a src/ user@host:/path/ | Local → remote |
rsync -a user@host:/path/ dest/ | Remote → local |
rsync -a -e "ssh -p 2222" src/ user@host:/path/ | Custom SSH port |
rsync -a -P src/ user@host:/path/ | Progress + keep partial |
Common Options #
| Option | Description |
|---|
-a | Archive (recursive + preserve) |
-v | Verbose |
-z | Compress during transfer |
-P | Progress + partial files |
--delete | Delete extras in dest |
--dry-run | Show changes only |
Ownership & Permissions #
| Option | Description |
|---|
-p | Preserve permissions |
-o | Preserve owner (root) |
-g | Preserve group |
--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r | Set permissions |
Handy Patterns #
| Command | Description |
|---|
rsync -a --info=progress2 src/ dest/ | Overall progress |
rsync -a --bwlimit=5m src/ dest/ | Limit bandwidth |
rsync -a --partial --append-verify src/ dest/ | Resume large files |
rsync -a --stats src/ dest/ | Summary stats |