Catalog / Rsync Cheatsheet

Rsync Cheatsheet

A comprehensive cheat sheet covering essential Rsync commands, options, and use cases for efficient file synchronization and backup.

Basic Usage

Core Syntax

rsync [OPTION...] SRC... DEST - Basic syntax for rsync command.

Local:
rsync [OPTION...] SRC... DEST

Remote:
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Pull: rsync [OPTION...] [USER@]HOST:SRC... DEST

Basic Examples

Syncing a local folder to another local folder:
rsync -avz ./source_folder /destination_folder

Syncing a local folder to a remote folder (push):
rsync -avz ./source_folder user@remote_host:/remote_destination

Syncing a remote folder to a local folder (pull):
rsync -avz user@remote_host:/remote_source ./local_destination

Syncing the contents of a source directory:
rsync -avz ./source_folder/ /destination_folder
Note the trailing slash on the source.

Important Notes

Trailing slash / matters! Use /source/ to sync content within source, and /source to sync the directory source itself.

-a implies -r (recursive), but be mindful of symlinks. If you don’t want to follow symlinks, use -l to copy them as links.

Essential Options

Transfer Options

-z, --compress

Enable compression during transfer to reduce bandwidth usage.

--partial

Allows resuming of aborted syncs, useful for large files or unreliable connections.

--bwlimit=RATE

Limits socket I/O bandwidth to a specified RATE in KB/s. Example: --bwlimit=200

--rsync-path=PATH

Tells rsync to execute from a specific path, useful if rsync isn’t in the system’s default path.

Display Options

-q, --quiet

Suppress non-error messages.

-v, --verbose

Increase verbosity. Use -vv or -vvv for even more details.

--stats

Show file transfer stats.

-h, --human-readable

Output numbers in a human-readable format.

--progress

Show progress during transfer.

-P

Equivalent to --partial --progress

Advanced Options

Skipping and Filtering

-u, --update

Skip files that are newer on the destination.

-c, --checksum

Skip files based on checksum, not modification time and size.

--exclude=PATTERN

Exclude files matching the specified pattern.

--include=PATTERN

Include files matching the specified pattern (overrides exclude).

--exclude-from=FILE

Read exclude patterns from FILE.

--include-from=FILE

Read include patterns from FILE.

--files-from=FILE

Read list of filenames from FILE to transfer.

-C, --cvs-exclude

Exclude files that would be excluded by CVS (from local/global .cvsignore files).

Deletion Options

--delete

Delete extraneous files from the destination directory. Use with caution!

--delete-before

Deletion happens before transfer.

--delete-after

Deletion happens after transfer. This is the default.

--delete-during

Deletion happens during transfer (less efficient).

--delete-delay

Find deletions during, defer until after.

Backup Options

-b, --backup

Backup with suffix.

--suffix=SUFFIX

Backup suffix (default ~ if --backup-dir not specified).

--backup-dir=DIR

Make backups into hierarchy under DIR.

--link-dest=DIR

Hardlink to files in DIR when unchanged.

Archive and Security

Archive Options

-a, --archive

Archive mode; equals -rlptgoD (no -H,-A,-X).

-r, --recursive

Recurse into directories.

-l, --links

Copy symlinks as links.

-p, --perms

Preserve permissions.

-t, --times

Preserve modification times.

-g, --group

Preserve group.

-o, --owner

Preserve owner (super-user only).

-D

Preserve devices and special files.

Security Options

--numeric-ids

Don’t map uid/gid values by user/group name.

--no-implied-dirs

Don’t send implied directories with --recursive.

--fake-super

Store/recover privileged attrs using a fake super account.

OSX Specific Exclusions

Common exclusions for macOS systems:
--exclude '.Trashes'
--exclude '.Spotlight-V100'
--exclude '.fseventsd'