Rsync on MacOS
The provided version of rsync on MacOS is disastrously outdated.
These are the steps to get an upto-date version that will allow you to sync MacOS specific features like labels and color flags. Since you are interested in a Command-line interface application I’m skipping the steps where you learn how to open and use a Terminal.
First of all, you need to install a modern version of rsync. To do this will use the Homebrew package manager.
Install Homebrew.
Homebrew is a package manager for MacOS. It provide an easy way to install all your favorite CLI applications.To install it simply type this command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update your Homebrew installation:
brew update
Install the coreutils package which contain up-to-date GNU File, Shell, and Text utilities:
brew install coreutils
After these steps you’ll have a good version of rsync that will accept way more options.
Here is the options I’m using to backup my most precious files:
rsync -avx --numeric-ids --times --progress --stats --human-readable --itemize-changes --delete --delete-excluded --exclude=--exclude=.Trashes/,.Trash/,.TemporaryItems/,.Spotlight-V100/,.fseventsd/,.DS_Store /Volume/source-folder/ rsync://server/user/destination-folder/
And the detail of these options:
—archive | -a | This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied. |
--verbose | -v | |
--one-file-system | -x | This tells rsync to avoid crossing a filesystem boundary when recursing. |
--xattrs | -X | This option causes rsync to update the destination extended attributes to be the same as the source ones. |
--compress | -z | With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted -- something that is useful over a slow connection. |
--numeric-ids | With this option rsync will transfer numeric group and user IDs rather than using user and group names and mapping them at both ends. | |
--progress | This option tells rsync to print information showing the progress of the transfer. This gives a bored user something to watch. | |
--stats | This tells rsync to print a verbose set of statistics on the file transfer, allowing you to tell how effective rsync's delta-transfer algorithm is for your data. | |
--human-readable | -h | Output numbers in a more human-readable format. |
--itemize-changes | -i | Requests a simple itemized list of the changes that are being made to each file, including attribute changes. |
--delete | This tells rsync to delete extraneous files from the receiving side (ones that aren't on the sending side), but only for the directories that are being synchronized. | |
--delete-excluded | In addition to deleting the files on the receiving side that are not on the sending side, this tells rsync to also delete any files on the receiving side that are excluded | |
--exclude=.Trashes/,.Trash/,.TemporaryItems/,.Spotlight-V100/,.fseventsd/,.DS_Store | list of excluded files |
Sources:
https://danielmiessler.com/blog/first-10-things-new-mac/#software
https://f-a.nz/dev/update-macos-rsync-with-homebrew/
https://zaiste.net/brand_new_rsync_for_osx/
https://github.com/rsnapshot/rsnapshot/commit/a3e67c91fecf4735915edd40a0714bbce7bf2bf4#diff-5c001016330a69ed47c778a626387174
https://rayed.com/posts/2014/10/rsnapshot-on-osx/