Skip to content

Instantly share code, notes, and snippets.

@martin-juul
Last active January 18, 2020 21:45
Show Gist options
  • Save martin-juul/c4eef859e343d216f4eae6b800d94a8f to your computer and use it in GitHub Desktop.
Save martin-juul/c4eef859e343d216f4eae6b800d94a8f to your computer and use it in GitHub Desktop.
rsync cheatsheet

Before you begin

These commands are currently only tested on macOS 10.13.4, running rsync 2.6.9.

Switches

If you just want to get to the meat. Examples are provided in the section underneath.

-avvz = archive, verbose x 2, compress

--times = preserve modification times

--stats = give some file-transfer stats

--checksum = skip based on checksum, not mod-time & size

--human-readable = output numbers in a human-readable format

--acls = preserve ACLs (implies -p)

--itemize-changes = output a change-summary for all updates

--progress = show progress during transfer

--out-format='[%t] [%i] (Last Modified: %M) (bytes: %-10l) %-100n'

%t = current date time

%i = an itemized list of what is being updated

%M = the last-modified time of the file

%-10l = the length of the file in bytes (-10 is for alignment and precision)

%-100n = the filename (short form; trailing "/" on dir) (-100 is for alignment and precision)

The cheatsheet

Show progress

rsync -P <rest-of-command>

Copy directory contents to destination directory (recursive). Remember trailing slash. Otherwise it will put the contents inside a directory, named after the parent.

rsync -r path/to/source/ /path/to/dest/

References

Sim's answer @ serverfault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment