Catalog / Rsync Cheatsheet
Rsync Cheatsheet
A comprehensive cheat sheet for using Rsync, covering essential options, examples, and use cases for efficient file synchronization and backup.
Rsync Basics
Basic Syntax
Example: |
Essential Options
|
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. |
Basic Examples
Copy a file to a remote server: |
Copy a directory recursively to a remote server: |
Synchronize two directories: |
Advanced Options
Deletion Options
|
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. |
Transfer Options
|
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. |
Filtering Options
|
Exclude files matching pattern. |
|
Include files matching pattern. |
|
Read exclude patterns from FILE. |
|
Read include patterns from FILE. |
Security and Remote Transfers
SSH Options
|
Specify a different SSH port. |
|
Specify a remote shell program. |
|
Specify where rsync is installed on the remote machine. |
Using SSH Keys
Ensure SSH keys are set up for passwordless authentication to avoid interactive prompts. Use |
Security Considerations
Always use secure protocols like SSH for remote transfers. |
Real-world examples
Backup
Incremental backup of a directory to an external drive: |
Daily incremental backup: |
Synchronization
Sync a website to web server: |
Mirroring
Create a mirror of a website: |