rsync, Synology NAS and Mac OS X

Talk about the Ultimate Question of Life, The Universe, and Everything
Post Reply
User avatar
The Source
Posts: 17879
Joined: 16 Nov 2011, 08:59
Location: Taipei

rsync, Synology NAS and Mac OS X

Post by rednoah » 16 Nov 2014, 17:46

rsync is a great tool for syncing files from one *nix machine to another. So syncing things from my Mac to and from my Synology NAS should be straight-forward right? WRONG! There's a plenitude of pitfalls, encoding, unicode decomposition, system files and of course the pre-installed rsync utility being severely outdated on OSX.

Do not use --archive since preserving owner/group/permissions will annoy you if you ever want to restore your files on a different machine.

--partial support resume for partial file transfers

--exclude .DS_Store Ignore system clutter files and exclude from syncing.

--delete-excluded Delete non-empty folders that only contain excluded files, i.e. delete empty folders that only contain .DS_Store files.

--iconv=UTF-8-MAC,UTF-8 OSX decomposes unicode characters implicitly, so names on the NAS (UTF-8 NFC) may not match the names on OSX (UTF-8 NFD) so it'll repeatedly sync files unless --iconv is set correctly.

However, --iconv is only supported on recent versions of rsync, so you'll need to install the latest rsync via brew.

-e Customise SSH options, e.g. turn off compression or use a key file instead of password login.

Here's the script is use to sync folders between my MacBook and my Synology NAS:

Code: Select all


export RSYNC_CMD="/usr/local/bin/rsync"
export RSYNC_OPTS="--recursive --times --links --executability --progress --human-readable --iconv=UTF-8-MAC,UTF-8 --prune-empty-dirs --delete-excluded --delete --exclude @eaDir --exclude .DS_Store --exclude Thumbs.db --exclude desktop.ini"
export RSYNC_SSH="ssh -T -o compression=no -i id_rsa"
export NAS_VOLUME="[email protected]:/volume1"

export DEST="$HOME/Archive/rsync-DS213J/"

for SRC in "data/Downloads" "data/Photos"
	echo "sync $NAS_VOLUME/$SRC to $DEST"

export DEST="$NAS_VOLUME/archive/rsync-MBP2015/"

for SRC in "Movies" "Pictures"
	echo "sync $HOME/$SRC to $DEST"
:idea: Please read the FAQ and How to Request Help.

Post Reply