Macos – Using rsync to synchronise folders without overwriting files of same name on Mac OS X

backupmacosrsyncterminal

I would like to synchronise the contents of two directories.

  • Without overwriting but to create a copy if two files have the same name, but different sizes
  • Without duplicating if two files have the same name and size.
  • To work recursively

So far I have found the following command which might work

 $ rsync -varE --progress ~/folder /volumes/server/folder

But I'm not entirely sure what the -E flag does. It was suggested by a user on bananica.com but couldn't see a description for it in the manual. Would this do what I require successfully?

Best Answer

-E actually preserves extended attributes on OS X, but -a (--archive) implies -p (--perms) which implies --executability.

-b (--backup) adds a tilde to the end of files that would normally get overwritten:

rsync -ab ~/folder /Volumes/server/

-b --suffix _old would rename file.txt to file.txt_old

rsync compares both file sizes and modification times by default. --size-only only compares sizes. -c compares checksums, but it's slower.

Related Question