Mac OS X File Sync

From Payne.org Wiki

Contents


I just got a Macbook and I want to sync files with my file server (running Linux). In particular, I want to be able to make off-line changes and have the sync operation do the right thing.

A friend suggested Unison, and here are my notes in setting it up. If you have a better suggestion, please let me know.

On the Linux Server

  1. Install Unison (You also may have to install Ocaml, because that's what Unison is implemented in). I run Gentoo Linux, so the install was simply:
 emerge unison

On the Mac OS X System

  1. Install Apple's X11 module. This can be found on the original installation CD under "Optional" components.
  1. Install Fink. This is a system that lets you manage and install open source packages onto your Mac OS X system.
  1. Open a terminal window and run this command to install Unison:
 fink install unison-nox

Synchronize Files

At this point, you should be able to synchronize files from the Mac back to the server, with the following command on the Mac:

 unison -batch {local dir} ssh://{remote.host}/{remote.dir}

The initial synchronization may take a while. You can check things out by modifying or deleting a file and rerunning unison to see if the changes propagate.

I sync my remote folder to a folder on my desktop, so the local directory looks something like:

 /Users/{your username}/Desktop/{foldername}

Set up a Shortcut

Once you've got everything configured, it's easy to set up a desktop or Dock shortcut to perform the sync operation in one click:

  1. Open the Terminal (in Applications, Utilities).
  2. Do a "Save As" and select "Execute this command". Enter the command you used above. (I saved to my Desktop, so I had a convenient link to sync).

I had to fiddle with the correct unison command, so it was easier to save the Terminal file (extension .term) and edit it with a text editor to get the command working correctly (it's just an XML file).

When you get it working, you can add "; exit" to the end of the command and it will close the shell window and exit when the sync is complete.

Since Unison uses SSH under the covers, it is really convenient to put an SSH key on your Linux server so you can log in without a password. (Note that this would provide login access to your server, however, should you ever lose your laptop). For more info on how to do this, see: [1]