RSYNC Commands Cheatsheet — Essential Reference

rsync is a fast, versatile, remote (and local) file-copying tool. It is widely used for backups, mirroring, and synchronizing files and directories efficiently.

Last updated: 2026-06-11

RECOMMENDED

Master RSYNC with Top Reference Books

Level up your DevOps skills. Find the best guide books and cheatsheet references for your engineering stack.

Search on Amazon →

Commands

Command Description Example
rsync -avz source/ destination/ Recursively copy files and directories, preserving permissions, ownership, timestamps, and enabling compression. rsync -avz /home/user/documents/ /mnt/backup/documents/
rsync -avz --delete source/ destination/ Synchronize directories, deleting files in the destination that are not present in the source. rsync -avz --delete /var/www/html/ /backup/web_data/
rsync -avz source/ user@remote_host:/path/to/destination/ Copy files and directories to a remote host over SSH. rsync -avz /home/user/data/ myuser@myserver.com:/home/myuser/backups/
rsync -avz user@remote_host:/path/to/source/ destination/ Copy files and directories from a remote host over SSH. rsync -avz myuser@myserver.com:/var/log/apache/ /home/user/logs/
rsync -avz --exclude 'pattern' source/ destination/ Copy files and directories, excluding files or directories matching a specified pattern. rsync -avz --exclude '*.tmp' --exclude 'cache/' /project/ /backup/project_backup/
rsync -avz --include 'pattern' --exclude '*' source/ destination/ Copy files and directories, including only files or directories matching a specified pattern (and excluding everything else). rsync -avz --include '*.jpg' --exclude '*' /photos/ /backup/jpg_photos/
rsync -P source/ destination/ Show progress during transfer and allow resuming interrupted transfers. rsync -P large_file.zip /mnt/usb_drive/
rsync -n source/ destination/ Perform a dry run, showing what would be copied without actually making any changes. rsync -avn /home/user/new_files/ /backup/daily_sync/

Pro Tips

  • Always use the `-n` or `--dry-run` option first to verify your rsync command will do what you expect before executing it for real.
  • Be careful with trailing slashes: `source/` copies the *contents* of source, while `source` copies the *directory itself* into the destination.
  • For very large transfers, consider using `--partial` with `--append-verify` or `--checksum` to ensure data integrity and allow resuming interrupted transfers efficiently.

Frequently Asked Questions

What is rsync used for?

rsync is primarily used for efficient file synchronization and backups, both locally and remotely. It minimizes data transfer by only copying the differences between source and destination files.

How do I install rsync?

rsync is often pre-installed on most Linux and macOS systems. If not, you can typically install it using your system's package manager: `sudo apt-get install rsync` (Debian/Ubuntu), `sudo yum install rsync` (CentOS/RHEL), or `brew install rsync` (macOS with Homebrew).