It's August, 2022; This is an updated answer:
Before getting into the answer here, you must know that although an rsync
binary is included with macOS, it is now an ancient, 16-year-old software package. On my Catalina system /usr/bin/rsync --version
reports itself as ver 2.6.9; released in Nov, 2006. The rsync
release history since ver 2.6.9 seems to make it clear that Apple's decision to halt upgrades for rsync
on their OS was based entirely upon the rsync
team's decision to switch to the GPLv3 license. This is unfortunate because rsync
ver 3.0 (the release following 2.6.9) included significant upgrades specifically supporting macOS users:
--xattrs
: preserves OS X extended attributes
--acls
: preserves OS X Access Control Lists
--fake-super
: allows non-admin users to preserve all attributes
The point of the above paragraph is simply this: If you want to use rsync
to back up files on your macOS, you must have a later version than the one Apple provides. Otherwise, you will lose all xattrs
and ACLs
- metadata that plays a significant role in several features of macOS. This is easily verified with a simple experiment.
Fortunately, current versions of rsync
are available from 3rd party macOS package managers (MacPorts for example), or for the DIY-inclined, you can clone the rsync
GitHub repo and build it from source.
It's also worth noting that a current version of rsync
can repair/restore a backup made previously using Apple's native rsync
ver 2.6.9. It can also repair/restore xattrs
, ACL
s and date-timestamps that have been mangled or lost by Apple's "Migration Assistant".
rsync
is a mature & comprehensive package with numerous options. Many of these options are not obvious choices, and one can spend a fair amount of time developing an option set to meet specific objectives. While there are no real shortcuts to careful consideration of your own use-case, I'll suggest the following option sets as a reasonable generic rsync
command for general use on macOS - a "point of departure" in other words. You may further tailor these to meet your own needs.
I'll present two cases for using rsync
to backup and restore; one using the --delete
option, and one without. Both cases assume the local Macintosh HD
is the source for the backup operation, and the destination for the restore operation. In my own case, there are some folders (e.g. Documents
) for which I prefer to use the --delete
option, and other folders (e.g. Music
, Pictures
& Movies
) in which I do not use --delete
. This is a personal choice that reflects how I manage/organize my data.
In the context of rsync
, the --delete
option simply means that deletions you make on your source folders are propagated to your destination folders.
Without the --delete
option:
1. In a BACKUP operation:
i. Source: /MacHD_Folder/
ii. Destination: /mountpoint/for/remote/storage
rsync -rlAXtgoDiv --fake-super /MacHD_Folder/ /mountpoint/for/remote/storage
2. In a RESTORE operation:
i. Source: /mountpoint/for/remote/storage
ii. Destination: /MacHD_Folder/
rsync -rlAXtgoDiv --fake-super /mountpoint/for/remote/storage/ /MacHD_Folder
With the --delete
option:
1. In a BACKUP operation:
i. Source: /MacHD_Folder/
ii. Destination: /mountpoint/for/remote/storage
rsync -rlAXtgoDiv --fake-super --delete --backup-dir=/mountpoint/for/remote/storage/deletes /MacHD_Folder/ /mountpoint/for/remote/storage
2. In a RESTORE operation::
i. Source: /mountpoint/for/remote/storage
ii. Destination: /MacHD_Folder/
rsync -rlAXtgoDiv --fake-super /mountpoint/for/remote/storage/ /MacHD_Folder
Note the asymmetry between backup & restore operations when using the --delete
option. This due to the fact that nothing need be deleted for the restore operation. Note also use of the --backup-dir
option when using the --delete
option: This causes rsync
to move all deleted files & folders to the designated folder on the destination drive. You may think of this as a form of "insurance" for deleted files - it functions as the Trash
folder does on your local MacHD.
Further Reading:
This GitHub recipe offers further explanations and useful options.