The intersection of technology and leadership

Synchronising two external hard drives with rsync on a mac

This is more of a reminder for myself so I don’t need to keep googling or looking at man when I need to look up the syntax.

Let’s assume you have two hard drives, ones called PHOTOS the other other PHOTOS_BACKUP. You can use the following command to sychronise photos (including removing all files that were deleted on PHOTOS to PHOTOS_BACKUP.) also ignoring backup files (.* files).

rsync -av --delete --exclude=".*" /Volumes/PHOTOS/ /Volumes PHOTOS_BACKUP

It’s nice to test this on a smaller folder first if you like. You should note the slash and lack of slash matters. To do a dry run try:

rsync -avn --delete --exclude=".*" /Volumes/PHOTOS/ /Volumes PHOTOS_BACKUP

or alternatively:

rsync -av --dry-run --delete --exclude=".*" /Volumes/PHOTOS/ /Volumes PHOTOS_BACKUP

Happy backups!

4 Comments

  1. Bill

    Thanks Pat! I was looking to do exactly this for my external drive with my media library. What is the purpose of excluding * files?

  2. Patrick

    Great. It’s not to exclude all files (*), but to ignore dot-star (.*) files which are often the backup or hidden files (e.g. IMG.JPG.bak) or on mac, there is always this .DS_Store file that gets created that I want to ignore by default

  3. Greg Lawrence

    Thanks Pat, I’m looking to do this but am not a programmer – and wanted to check – do I type these commands in Terminal?
    Thanks! Greg

  4. Patrick

    Hi Greg! Yes, you’re right. These should be typed in the command line which can be done via Terminal

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2020 patkua@work

Theme by Anders NorenUp ↑