OS X

How To Sync Files and Folders on the Mac

To keep multiple folders and thousands of files synchronised can be a real headache without a convenient method to automate the task.

Consider this scenario: you have several folders on your Mac that must be kept fully synchronised with an external USB memory stick, hard drive, or simply with another computer or mobile phone. Copying files manually can be just too time consuming and it’s easy to miss a few files, so inevitably you end up with multiple versions in each location.

On the Mac, it’s easy to synchronise any numbers of files and folders; the most common methods are:

  1. With third-party apps from the App Store
  2. With the built-in rsync Terminal utility
  3. With rsync in combination with Automator
Each method is described in more detail below.



METHOD 1: Third-Party Apps

There are a dozen or so third-party apps available in Mac App Store that can simplify and automate the process of keeping files and folders synchronised. Additionally, cloud-based services such as Dropbox can synchronise files on multiple machines very simply (note that the Mac version of Dropbox is only available from their website, not in the App Store).

For most people a third-party app is the most convenient and hassle-free method to sync your data, with the advantage that lots of features are provided such as the ability to sync files, music, pictures, bookmarks and other data.

Some of the most popular synchronisation apps are:

Third Party Synchronisation Apps

METHOD 2: rsync Utility

Rsync is a very useful utility built into Mac OS X which allows the differences between two sets of files to be synchronised. Rsync can also sync data over a network, so if your folders are on another computer this method can be tweaked slightly to use the relevant remote hostname.

To use rsync follow the steps below.

1. Open Terminal from the Utilities folder or Spotlight

2. In the Terminal window type rsync -aE –delete ~/ <source folder> / “<destination folder>”

For example:

rsync -aE –delete “~/Documents/” “/Volumes/Macbook Pro Backup/”

This example keeps everything in the Home Folder’s Documents directory synchronised with the external disk named MacBook Pro Backup and deletes anything in the destination folder which isn’t already in the source folder. This example creates a copy of Documents in the top level of the external disk’s folder structure.

Note: rsync is a very powerful tool that has dozens of command-line options, so it’s worth reading the user manual in more depth (in Terminal, just type man rsync and press Enter).

METHOD 3: rsync Utility + Automator

While rsync certainly gets the job done, it’s much more useful when combined with Automator to simplify the whole process. This method is particularly effective when you have multiple folders in different locations that need to be synchronised, because you can enter any number of rsync commands into the script.

1. Open Automator from the Applications folder or within Spotlight

2. Choose Workflow when prompted, as below

Automator New Workflow
Create a new workflow in Automator

3. Search for the Run Shell Script action in the search field, then drag the icon into the main window on the right-hand side

Find Run Shell Script
Find the Run Shell Script command in the Actions list

4. In the Run Shell Script dialogue, change the Pass input drop-down field to as arguments

5. Under Options at the bottom of the workflow, make sure the checkbox labelled Ignore this action’s input is checked. The reason is that it’s just going to run as a standalone script and won’t take any files as input

6. In the Run Shell Script dialogue, delete any commands already included by default and replace them with the appropriate rsync commands. Make sure  you specify the correct source and destination folders

Run Shell Script window
Enter the appropriate rsync commands into the workflow

7. Choose Save from the File menu and save the workflow as an application, then hit the Save button

Save your Automator app
Save your workflow as an application

8. Now just run the application you’ve created whenever you want to synchronise the selected folders

Note that it’s possible to add your sync app to the Login Items (under System Preferences -> User & Groups) to run every time you login, or to create a scheduled task to run the script on a regular basis.

You might also like to copy the application into the startup items folder to run every time your computer starts. The startup folder on your Mac is at //Macintosh HD/Library/StartupItems but note that in the case of an external drive or USB stick it would need to be connected to run successfully.

Add rsync as a login item
Run your synchronisation app every time you login

Before you go

After spending over 20 years working with Macs, both old and new, theres a tool I think would be useful to every Mac owner who is experiencing performance issues.

CleanMyMac is highest rated all-round cleaning app for the Mac, it can quickly diagnose and solve a whole plethora of common (but sometimes tedious to fix) issues at the click of a button. It also just happens to resolve many of the issues covered in the speed up section of this site, so Download CleanMyMac to get your Mac back up to speed today.

mac-pc

About the author

Roland Banks

I've been passionate about Apple ever since I bought my first iPod followed by a white polycarbonate MacBook in 2007. I currently own a MacBook Pro Retina, an iPad Mini Retina, and an iPhone 6.

9 Comments

Click here to post a comment

Leave a Reply

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