OS X El Capitan (10.11.4) comes with an outdated version of rsync (2.6.9) due to licensing issues. It's easy to build the latest rsync from source. I followed this guide, adapted for rsync 3.1.2.
cd ~/Desktop
curl -O https://download.samba.org/pub/rsync/src/rsync-3.1.2.tar.gz
curl -O https://download.samba.org/pub/rsync/src/rsync-patches-3.1.2.tar.gz
tar -xvf rsync-3.1.2.tar.gz
tar -xvf rsync-patches-3.1.2.tar.gz
cd rsync-3.1.2
patch -p1 < patches/fileflags.diff
patch -p1 < patches/crtimes.diff
patch -p1 < patches/hfs-compression.diff
./configure
make
Once rsync is built, you can optionally run sudo make install
to put the binary in /usr/local/bin.
fileflags preserves the st_flags stat() field (see sys/stat.h). Adds --fileflags option, as well as some --force-* options.
crtimes preserve create times. Adds --crtimes (-N) option.
hfs-compression adds support for HFS+ compression. Adds --hfs-compression and --protect-decmpfs options. A diff of the --help output between standard and patched versions of rsync.
Backup Bouncer is useful for verifying your rsync arguments. I used the fork by mbaltaks, which seemed to have more recent fixes and updates. The test files bbouncer creates utilize basic permissions, timestamps, symlinks, symlink ownership, hardlinks, resource forks, finder flags, finder locks, create dates, BSD flags, extended attributes, HFS compression, and ACLs. You can decide which you want to preserve and experiment with different rsync options until you're satisfied.
./bbouncer create-vol mysrc
./bbouncer create-vol mydst
./bbouncer create /Volumes/mysrc/
rysnc --your-options /Volumes/mysrc/ /Volumes/mydst/
./bbouncer verify -d /Volumes/mysrc/ /Volumes/mydst/
A simple rm -rf
may not be able to delete the test files bbouncer creates. Use the clean command instead.
./bbouncer clean /Volumes/mydst
Here's what I currently use to backup my files to another HFS+ disk. These arguments pass all of the bbouncer tests, though that's not required depending on your backup strategy.
rsync -aNHAx --hfs-compression --force-change --delete
Note that hfs-compression and protect-decmpfs imply the following options:
This is equivalent to the command above, but includes implied options for clarity:
rsync -aNHAXx --fileflags --hfs-compression --force-change --delete