Basic Commands
Syntax
rsync [OPTIONS] SOURCE DESTINATION
Trailing slash matters:
rsync -av /src/ /dest/ # copies contents OF src into dest
rsync -av /src /dest/ # copies the src FOLDER into dest
Essential Commands
| Command | What It Does |
|---|---|
rsync -av src/ dest/ | Archive mode (preserves everything) |
rsync -avz src/ user@host:dest/ | Compressed remote transfer |
rsync -avP src/ dest/ | Show progress + allow resume |
rsync -avn src/ dest/ | Dry run — preview only |
rsync -av --delete src/ dest/ | Mirror source, delete extras |
rsync -avz -e "ssh -p 2222" src/ user@host:dest/ | Custom SSH port |
rsync -av --exclude='*.log' src/ dest/ | Exclude by pattern |
rsync -av --include='*.conf' --exclude='*' src/ dest/ | Include only .conf |
Direction
| Pattern | Direction |
|---|---|
rsync local/ remote:path/ | Push — local → remote |
rsync remote:path/ local/ | Pull — remote → local |
rsync src/ dest/ | Local — same machine |