Your cart is currently empty!
Rsync Command Cheatsheet

rsync is a versatile command-line tool for efficiently synchronizing files and directories between local and remote systems. It’s useful for various tasks, including backups and data transfer. Here’s a quick cheatsheet to help you master rsync commands:
1. Copy Files from Local to Remote:
rsync -avzP /source/ user@remote:/destination/
- -a: Archive mode (preserves permissions and more).
- -v: Verbose mode (display progress).
- -z: Compress files during transfer.
- -P: Show progress and allow resuming.
This command copies files from a local directory to a remote server. Replace /source/ with your local directory path and user@remote:/destination/ with your server credentials and destination path.
2. Copy Files from Remote to Local:
rsync -avzP user@remote:/source/ /destination/
- Options same as in #1.
Use this command to pull files from a remote server to your local machine.
3. Exclude Unnecessary Files and Directories:
rsync -avzP --exclude=folder/ /source/ user@remote:/destination/
- Additional
--excludeflags to exclude specific folders or files.
Exclude unnecessary files or directories by specifying them with --exclude.
4. Delete Remote Files Not Present Locally:
rsync -avzP --delete /source/ user@remote:/destination/
--delete: Delete remote files not present locally.
Ensure that files deleted locally are also removed from the remote server during synchronization.
5. Specify SSH Key and Port:
rsync -avzP -e "ssh -i /path/to/private/key -p 22" /source/ user@remote:/destination/
-e: Specify the SSH command with options.
Use this when connecting to a remote server with a non-standard SSH key or port.
6. Dry Run (Preview Changes):
rsync -avzP --dry-run /source/ user@remote:/destination/
--dry-run: Simulate the rsync operation without making changes.
Preview changes before syncing with this command.
7. SSH Compression (Faster Transfer):
rsync -avzP -e "ssh -C" /source/ user@remote:/destination/
-C: Enable SSH compression.
Speed up transfer by enabling SSH compression for data transmission.
Feel free to customize these commands to suit your specific needs when working with rsync.
Comments
2 responses to “Rsync Command Cheatsheet”
-
Howdy! This post couldn’t be written any better!
Reading through this article reminds me of my previous roommate!
He continually kept preaching about this. I most certainly will
send this article to him. Pretty sure he’s going to have a good read.
Thank you for sharing!-

Thanks Jose! I’m glad you found it useful, Rsync is an awesome tool and I’m sure we will all be using it for many years to come!
-

Leave a Reply to Jose Goens Cancel reply