rsync [options] source destination
Example:
rsync -avz /path/to/source/ user@host:/path/to/destination/
A comprehensive cheat sheet for using Rsync, covering essential options, examples, and use cases for efficient file synchronization and backup.
Example: |
|
Archive mode; preserves permissions, ownership, timestamps, etc. |
|
Verbose mode; increases the amount of information displayed during the transfer. |
|
Compress file data during the transfer. |
|
Recursively copy directories and files. |
|
Preserve modification times. |
|
Preserve owner. |
|
Preserve group. |
|
Preserve permissions. |
Copy a file to a remote server: |
Copy a directory recursively to a remote server: |
Synchronize two directories: |
|
Delete extraneous files from the destination directory. |
|
Deletion happens before transfer. |
|
Deletion happens after transfer. |
|
Deletion happens during transfer. |
|
Also delete excluded files from destination. |
|
Show progress during transfer. |
|
Keep partially transferred files if the transfer is interrupted. |
|
Skip files based on checksum, not modification time and size. |
|
Skip updating files that exist on destination. |
|
Remove source files after successful transfer. |
|
Don’t transfer any file larger than SIZE. |
|
Exclude files matching pattern. |
|
Include files matching pattern. |
|
Read exclude patterns from FILE. |
|
Read include patterns from FILE. |
|
Specify a different SSH port. |
|
Specify a remote shell program. |
|
Specify where rsync is installed on the remote machine. |
Ensure SSH keys are set up for passwordless authentication to avoid interactive prompts. Use |
Always use secure protocols like SSH for remote transfers. |
Incremental backup of a directory to an external drive: |
Daily incremental backup: |
Sync a website to web server: |
Create a mirror of a website: |