nerdicism
Bitte denken Sie an die Umwelt bevor Sie diese Seite ausdrucken.
Two Macs, an iPhone sharing one life
Categories: Science & Technology | Written by ninan

Today I switched my standard browser from Safari to Firefox. I had done this before, but I first had to solve some synchronization issues, as my life is supported by my two Macs (iMac, MacBook) and an iPhone so I need to hold my data in sync on all of them.

I have the following things in sync at the moment:

  • Bookmarks between computers and browsers (Firefox, Safari, Mobile Safari)
  • Passwords
  • Contacts
  • Calendars
  • Preferences
  • Mail Accounts
  • iTunes library
  • Documents folder
  • Java development tools (Eclipse, NetBeans, maven, tomcat, …)
  • GPG keys
  • Zotero
  • OmniFocus

For all this sync magic I use

  • A MobileMe subscription for bookmarks on the iPhone, passwords, contacts, calendars, preferences and mail account settings
  • Foxmarks for bookmarks between Macs and Browsers (Safari and Firefox)
  • Unison for all file synchronization tasks (iTunes, Documents, Java development stuff, GPG keys, Zotero)

In the following howto I outline the steps necessary to get synchronization to work for you.

Most of these steps need you to have access to an administrative account (e.g. the first you created on your Mac) to work.

BE WARNED: I am not responsible for any data loss, malfunction or any other inconvinience you encounter by following this howto. It worked for me, it might not work for you as well. Be sure to have a backup of all your data.

MobileMe

MobileMe is tightly integrated with Mac OS X and all one has to do is to get a subscription. Unfortunally MobileMe is an all or nothing offer so you cannot only buy the sync services. As soon as you added your Macs to MobileMe cloud, everything should work fine. I have activated all sync modules on one of my Macs (Your mileage may vary) and everything except Bookmark sync on the other (could be others, but I only have two macs in my lifecycle right now). If I didn´t deactivate Bookmark sync on all but one Mac, I had to accept recreation of ALL my bookmarks after every sync with Foxmarks. If I deactivate it on both (all) Macs, I wouldn´t get the iPhone in sync.

Step by step:

  1. Get MobileMe subscription
  2. Put your Macs and iPhone into the cloud
  3. Activate all the sync services you need
  4. Deactivate MobileMe bookmark sync on all but one Mac

Foxmarks

Foxmarks is a bookmark and password sync service. It is ran by a company founded by an ex-Mozilla board member. Using the Foxmarks bookmark sync service is free as in beer.

The Safari plugin is a little system extension, that adds itself to the menu bar and preference pane. Pratically it also contains an uninstaller.

For Firefox there is an extension (what else?).

Step by step:

  1. Open Safari and go to http://download.foxmarks.com/download
  2. Download the dmg and open it from your downloads directory
  3. Run the installer
  4. Choose to create an account when the wizard comes up
  5. Fire up Firefox and go to https://addons.mozilla.org/de/firefox/addon/2410.
  6. Click to install the extension
  7. After Firefox restart a wizzard comes up. Choose to not create a new account and enter the credentials of your Foxmarks account.
  8. Repeat this process on each of your Macs (and/or PC)

Now you should have bookmark sync running between all your Macs (and PCs if you mind) and your iPhone – and as a side effect the same bookmarks in Safari and Firefox.

Unison

Unison is a command line tool (Runs in Terminal) that is able to do two-way file synchronization. I use it to hold various directories in sync on my Macs. A less complex solution was to use the iDisk of MobileMe, but this would imply you hold the relevant data on that iDisk which might not be possible at all.

Although it is supposed to work, I never used it to connect more than two Macs or PCs. I also didn´t ever try to connect different operating systems (e.g. Mac OS X and Linux). But I never had problems doing sync between two hosts of the same operating systems.

MacPorts

Unison is contained in MacPorts, the Mac OS X ports collection hosted by Apple Inc. You need to install it first.

Download the disk image (.dmg) and install MacPorts following the usual steps. If you don´t like to use the Terminal to install things, download and install Porticus. It will provide you with a great GUI for MacPorts.

Now update your ports list by running

sudo port selfupdate

or in Porticus select “Ports -> MacPorts selfupdate” from the main menu.

…and back to Unison

To install Unison open Terminal or Porticus.

For Terminal type

sudo port install unison

For Porticus select “All ports” from the left pane and type “unison” into the search box. Select “unison” from the search result and click “Install” in the toolbar.

There will pop up a window showing you the available variants. Select nothing and click “install”.

Repeat these steps on your other Mac.

Configuring Unison

Final step. As template process lets create a new directory inside your personal folder on one Mac called UnisonTestDir. Copy some random files into it.

Open your user´s directory in Finder and go to Library/Application Support. There should be a directory called Unison, if not, create it.

Open any text editor (Not TextEdit) you like. Copy the following template into the editor:

# Unison preferences file
root = /Users/user/UnisonTestDir
root = ssh://user@ip.of.other.mac//Users/user/UnisonTestDir
ignore = Name .DS_Store

Replace user with your short username and ip.of.other.mac with the IP-Adress or hostname of the other computer.

Save this file as UnisonTestDir.prf inside Library/Application Support/Unison .

If you type the following into the Terminal:

unison -servercmd "/opt/local/bin/unison" UnisonTestDir

Now you should get:

Contacting server...
Warning: No xauth data; using fake authentication data for X11 forwarding.
Connected [//Localmac.local//Users/user/UnisonTestDir -> //RemoteMac.local//Users/user/UnisonTestDir]
Looking for changes
Warning: No archive files were found for these roots, whose canonical names are:
	/Users/user/UnisonTestDir
	//RemoteMac.local//Users/user/UnisonTestDir
This can happen either
because this is the first time you have synchronized these roots,
or because you have upgraded Unison to a new version with a different
archive format.

Update detection may take a while on this run if the replicas are
large.

Unison will assume that the 'last synchronized state' of both replicas
was completely empty.  This means that any files that are different
will be reported as conflicts, and any files that exist only on one
replica will be judged as new and propagated to the other replica.
If the two replicas are identical, then no changes will be reported.

If you see this message repeatedly, it may be because one of your machines
is getting its address from DHCP, which is causing its host name to change
between synchronizations.  See the documentation for the UNISONLOCALHOSTNAME
environment variable for advice on how to correct this.

Donations to the Unison project are gratefully accepted:

http://www.cis.upenn.edu/~bcpierce/unison

Press return to continue.[<spc>]

Hit the space bar and Unison will start to copy things over:

Reconciling changes

local          RemoteMac...      
dir      ---->            /  [f] ?

Hit f and y to start the sync process:

Proceed with propagating updates? [] y
Propagating updates

UNISON 2.27.57 started propagating changes at 22:43:19 on 10 Mar 2009
[BGN] Copying  from /Users/user/UnisonTestDir to //RemoteMac.local//Users/user/UnisonTestDir
[END] Copying
UNISON 2.27.57 finished propagating changes at 22:43:19 on 10 Mar 2009

Saving synchronizer state
Synchronization complete  (1 item transferred, 0 skipped, 0 failures)

Now run

unison -servercmd "/opt/local/bin/unison" UnisonTestDir

again. There should be:

Contacting server...
Warning: No xauth data; using fake authentication data for X11 forwarding.
Connected [//LocalMac.local//Users/user/UnisonTestDir -> //RemoteMac.local//Users/user/UnisonTestDir]
Looking for changes
  Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.

You can repeat these steps for any directory you want. Simply create a profile per directory and adjust the values. I use Unison for a whole bunch of directories including iTunes and Documents without bigger problems for years now.

You have to consider, that Unison can become very complex when it comes to synchronization conflicts. Especially you have to care about iTunes and other database-backed software, so that only one instance of it (iTunes) might be run on one computer between two synchronization processes.

Unison convenience

Because always calling

unison -servercmd "/opt/local/bin/unison" UnisonTestDir

all the time is very annoying, I built a little Bash-Script that will run unison for every existing profile:

#! /bin/sh
servercmd="/opt/local/bin/unison"
for profile in /Users/ninan/Library/Application Support/Unison/*.prf
do
	baseprofile=`basename "$profile" .prf`
	echo "Synchronizing $baseprofile"

	/opt/local/bin/unison $baseprofile -auto -servercmd "$servercmd" -ui text
done

Save this file to /Users/user/bin/syncws and make it executable. Now all you should have todo is to run syncws in Terminal every time you want to synchronize your directories.

If you found these Unison steps hard to follow because all of the shell work, it isn´t probably for you.

Conclusion

Apart from MobileMe everything is free and apart from Unison everything happens automatically (most of the time).

You should consider, that either MobileMe and Foxmarks put your data onto servers outside your reach. I consider Apple trustworthy and aware of their responsibilty (They state to encrypt your data with your MobileMe password) and my bookmarks are not that critical in terms of privacy that I wouldn´t give Foxmarks a shot.

I would like to replace the MobileMe sync services with something free and open, but this decision has to be made within a year from now since I just renewed my subscription (BTW Today I´ve found out about fruux as they started to follow me on Twitter). I will look for alternatives in the near future.

Unison, if used right and with a bit of care, is hell of a tool. I use it for years now on either Linux and Mac OS X without big pain. But since with great power comes great responsibility, you should think twice about implementing the Unison solution. Unfortunally I wasn´t yet able to find working and stable GUIs for Unison apart from the command line interface.

OmniFocus, btw. supports several synchronization strategies out of the box. I use idisk based synchronization.

Leave a Reply