Dropbox: Symbolic links to share databases all your computers

Posted on by Mike Evans

If there is one application that gets universal approval and which is used by every geek in the Mac universe it has to be Dropbox. I've raved about it before but, if you don't know by now, Dropbox creates a folder on your computer which then synchronises with the Dropbox server. Unlike MobileMe’s iDisk, where you have to make a conscious decision to mount the drive, the Dropbox folder is always there and acts just like any other folder on the Mac. It holds a local copy of all your data and this is reproduced on the Dropbox server and on as many linked computers as you wish, not just Macs. If you are offline, everything is there and can be worked on; it will sync automatically as soon as you are connected again.

If you have sensitive material in Dropbox you can choose (from the Dropbox website) which of your linked computers should have access. This is also a useful facility if one of your computers has limited storage, such as with a 64GB MacBook Air. In the case of the iOS Dropbox applications, however, you choose the individual files you want to see from within the app.

For convenience I keep my Dropbox folder on the Desktop and treat is as the main storage location, completely replacing the Documents folder on the Mac. This way the data is instantly accessible. For free you get 2GB of storage which means you can ensure all your vital stuff is constantly backed up off site. Subscriptions are available for 50GB or 100GB if you want to store more data.

Database sync

One of the most satisfying feats of Dropbox is synchronisation of databases. For instance, the data for my accounts system, my 1Password keychain, my OmniFocus database and all my Numbers documents are on Dropbox. I've been synchronising in this way for over two years and I have never encountered a single problem or loss of data. Whether I am working on my desktop computer or abroad on my MacBook Air I am looking at the same set of data and everything is always up to date. What's more, everything is backed up to the Dropbox cloud in case the worst should happen.

There is a caveat, of course: Make sure applications are closed and files saved on one Mac before trying to open the synchronised document on another. Most our Mac applications do not support multi-user databases, but this isn’t a problem as long as you are the only user and won't be trying to access the same data on more than one computer at a time. Finally, bear in mind that although Dropbox sync is quick, you do need to wait a few minutes for the files to sync before rushing from one computer to the other. 

So you get the picture. I love Dropbox.

When the datafile is in fixed location

Occasionally, though, you come across a program that insists on looking for its data in a specific location – more than likely in ~Library/Application Support. The official advice from developers is that there’s nothing they can do and they do not recommend using Dropbox to synchronise their data with other computers. You can understand the reluctance because there is a high risk of data corruption or lost data if you try to open the same file on two computers at the same time.

All is not lost, though. If you understand the potential problems, you can synchronise databases by using a symbolic link between the database folder in Application Support and your Dropbox folder. Nothing is guaranteed but a similar symbolic link on your other Macs should allow the one database to be used everywhere. I say with luck, simply because we are not dealing with multi-user systems and you have to use common sense or you will lose data.

The snag with all this is that creating a symbolic link involves a fair bit of prestidigitation in Terminal and isn't for the faint of heart. Big damage can be done with Terminal commands if you make a mistake.

MacDropAny makes it simple

Fortunately there is now a simple way of creating symbolic links without having to use Terminal. MacDropAny is a small, free utility created by Sebastian Hallum Clarke which does the hard work for you. Just install it, run it and you are prompted to choose a source folder on your computer and a target folder on Dropbox. It's as simple as that. Even simpler, if you wish, you can drag a folder to the MacDropAny icon and follow the prompts.

By default, MacDropAny will prompt you to make a link from your computer to your Dropbox folder. This results in the data remaining where it is supposed to be - usually in Application Support - with Dropbox containing a symbolic link to the original folder.

I prefer to do it the other way round--a symbolic link from Dropbox back to Application Support. First step is to move the database to Dropbox and then create a symbolic link back to the Application Support folder in your user Library. You can then repeat the process on your other computers so that Dropbox holds the master folder but your applications find what they are looking for in the symbolically linked folder in Application Support.

If you do decide to try this out, make sure that you start with one up-to-date set of data.  This isn’t going to work if you have been using an application on two computers and have two sets of data. You need to choose which one to use and delete or archive the other. Once you have it running, though, all should work well provided you bear in mind the warning of not trying to work on the data simultaneously on more than one machine (or, perhaps, leaving the data file on one computer unsaved before moving to another location).

As Dan Frakes points out in his recent Macworld article, there are a number of caveats to the use of symbolic links. The most important advice is to link only folders and not individual files; but you should also not link your Applications folder, tempting as it might be. Linking iPhoto and iTunes folders is also not recommended, though many have done it successfully.

After the break is a step-by-step guide to setting up your databases.


Moving data to Dropbox and linking back to original location

This a step-by-step guide to linking a database for a typical application, MarsEdit, to Dropbox. MarsEdit is one of those programs (Bento is another) which expects to find its data locally in ~/Library/Application Support and cannot be redirected to Dropbox from within the application.

Most programs these days do allow you to choose a location for the folder. You should first check the situation in the Preferences pane of the application before bothering with symbolic links. If there is definitely no developer-approved method of relocating the database, this is what to do: 

Note that the tilde ~ before /Library/Application Support indicates the name of your home folder. An example of the full path is:  mikesmacpro/Library/Application Support

  1. Close the application, in this case MarsEdit.

  2. Find the MarsEdit folder in ~/Library/Application Support and copy it to a convenient temporary backup location (I suggest the Desktop). This is a safety backup which you can restore to its original location if things don't work out.

  3. Now move the MarsEdit folder from Applications Support to Dropbox. If you wish you can put it in a sub-folder on Dropbox, for instance one called Databases--but create this first before starting the move. This avoids too much clutter inside the Dropbox folder. If you did a copy and paste instead of move, delete the original MarsEdit folder from its location in ~/Library/Application Support.

  4. Open MacDropAny and you will be asked to choose a folder on your computer. You don't want to do this because you are creating a reverse link from Dropbox to your computer. Instead navigate to Dropbox and choose the MarsEdit folder you have just moved there.

  5. Now MacDropAny will prompt you for a location for the link and will suggest a name which should be the same as the original folder you earlier removed from Application Support, in this case “MarsEdit”. Accept this and do not change it.  

  6. Navigate to ~/Library/Application Support on your Mac and confirm the action to create the symbolic link.

You now have your MarsEdit data folder on Dropbox and an symbolic folder (also called MarsEdit) in ~/Library/Application Support. Open MarsEdit. It will look at the folder in the Library and see its data as usual. Any changes will be instantly reproduced in the Dropbox folder.

Once you've ensured this is working satisfactorily you can delete the backup folder you placed on the Desktop (or, better still, move it to a another location where you can find it again in emergency).

Linking on other computers

Now go to your second computer and follow steps 4 and 5 above by creating a link from the MarsEdit data on Dropbox to ~/Library/Application Support. First, though, backup and then delete the MarsEdit database folder inside Application Support on the second computer. If you are installing MarsEdit for the first time on another computer there will be no existing data folder. In this case I recommend creating the symbolic link to ~/Library/Application Support before installing the program. When you do this, it will simply adopt the folder as though there had been a previous installation.

Bear in mind that this method is not approved by the developers of MarsEdit (Red Sweater Software) and you do it at your own risk. But provided you have a backup of the entire MarsEdit folder you can easily go back to square one if you have to.

I now have MarsEdit working from Dropbox on my MacBook Air and on my desktop machine at home. I have also successfully linked my Bento database in the same way. Again, it isn’t recommended by Bento but it works. As with any change of this nature, though, make absolutely sure you have an up-to-date backup of the entire database folder stored elsewhere before you start tinkering. You can never have enough backups in any case. 

More reading: Sebastian's posts on the Dropbox user forum.

If you discover any problems with the above guide or would like to add some further tips, please get in touch.

Technorati Tags: , , ,

∞ Permalink