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
#!/bin/bash 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" #SYNC FROM NAS export DEST="$HOME/Archive/rsync-DS213J/" for SRC in "data/Downloads" "data/Photos" do echo "sync $NAS_VOLUME/$SRC to $DEST" $RSYNC_CMD $RSYNC_OPTS -e "$RSYNC_SSH" "$NAS_VOLUME/$SRC" "$DEST" done # SYNC TO NAS export DEST="$NAS_VOLUME/archive/rsync-MBP2015/" for SRC in "Movies" "Pictures" do echo "sync $HOME/$SRC to $DEST" $RSYNC_CMD $RSYNC_OPTS -e "$RSYNC_SSH" "$HOME/$SRC" "$DEST" done