Skip to main content

rsync Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for rsync commands and options

Rsync is a fast file sync tool for local and remote transfers. This cheatsheet covers the most common rsync commands, options, and patterns.

Install

CommandDescription
sudo apt install rsyncInstall on Debian/Ubuntu
sudo yum install rsyncInstall on RHEL/CentOS
sudo dnf install rsyncInstall on Fedora

Basic Syntax

CommandDescription
rsync [OPTION] SRC DESTLocal sync
rsync [OPTION] SRC USER@HOST:DESTLocal → remote
rsync [OPTION] USER@HOST:SRC DESTRemote → local

Local Sync Examples

CommandDescription
rsync -a src/ dest/Mirror contents
rsync -a src dest/Copy dir into dest
rsync -av src/ dest/Verbose sync
rsync -a --delete src/ dest/Delete extra files

Remote over SSH

CommandDescription
rsync -a src/ user@host:/path/Local → remote
rsync -a user@host:/path/ dest/Remote → local
rsync -a -e "ssh -p 2222" src/ user@host:/path/Custom SSH port
rsync -a -P src/ user@host:/path/Progress + keep partial

Common Options

OptionDescription
-aArchive (recursive + preserve)
-vVerbose
-zCompress during transfer
-PProgress + partial files
--deleteDelete extras in dest
--dry-runShow changes only

Excluding Files

CommandDescription
rsync -a --exclude 'node_modules' src/ dest/Exclude by name
rsync -a --exclude-from='exclude.txt' src/ dest/Exclude from file
rsync -a --include='*.jpg' --exclude='*' src/ dest/Include pattern

Ownership & Permissions

OptionDescription
-pPreserve permissions
-oPreserve owner (root)
-gPreserve group
--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=rSet permissions

Handy Patterns

CommandDescription
rsync -a --info=progress2 src/ dest/Overall progress
rsync -a --bwlimit=5m src/ dest/Limit bandwidth
rsync -a --partial --append-verify src/ dest/Resume large files
rsync -a --stats src/ dest/Summary stats