Basic Format
rsync options source destinationKey Options
-v | Increases verbosity. |
|
-r | Recursive, copies directories recursively. |
|
-a | Archive mode, preserves permissions, ownerships, etc. |
|
-z | Compress file data during the transfer. |
|
-h | Output numbers in a human-readable format. |
|
--delete | Delete extraneous files from destination dirs. |
|
--progress | Show progress during transfer. |
|
-e ssh | Specify the ssh as remote shell. |
|
--exclude | Exclude files matching pattern. |
|
--include | Don't exclude files matching pattern. |
Examples
rsync -avzh source destination
Sync files/dirs between local and remote host.
rsync -avzhe ssh user@remote:/source /destination
Sync files/dirs from remote host to local host.
rsync -avzhe ssh /source user@remote:/destination
Sync files/dirs from local host to remote host.
rsync -avzh --delete source destination
Sync with deletion where if a file/directory is removed from source, it will be removed from destination.
rsync -avzh --progress source destination
Sync with progress output.
rsync -avzh --exclude 'Dir*' source destination
Sync while excluding directories/files that match pattern.
rsync -avzh --include 'Dir*' --exclude '*' source destination
Sync only directories/files that match pattern.