As great as MarsEdit is (and it is great), it doesn’t yet let me sync drafts across multiple machines. With respect to WordPress (and some other CMSs), MarsEdit does allow you to save your posts as drafts on your web server; however, I have a general aversion to this because it requires that I remember to update the timestamp of the post (to the current date/time) when I actually publish it, and also causes the post IDs to stray from date-order (I know, I’m anal).
A couple of months ago a friend mentioned Dropbox (currently in private beta) in passing, and immediately I wondered if I could use such a service to do what I needed with respect to MarsEdit (and OmniFocus; see below). Turns out I could.
To get Dropbox to play nice with MarsEdit you have to use symbolic links (because, as far as I know, MarsEdit doesn’t let you specify where you want to store your drafts and other data), and Dropbox will sync only what you drop into the Dropbox folder. The trick to using symbolic links in this scenario is two-fold: 1) you must make sure your usernames on each machine are the same; and 2) you must time correctly the creation of the symlinks on each machine.
Regarding the first point, it must be understood that when you use the ln command to create a link, it resolves the tilde so that the path to the linked-to file contains your username (i.e., ~/Dropbox –> /path/to/username/Dropbox). In light of this, the usernames on every syncing machine must match up, else the last machine to talk to the Dropbox folder will overwrite the symlink to point to the username on its machine; this obviously will break the symlink on the other machine because it will then point to a path that does not exist on that machine.
Even if each instance of MarsEdit is being run under the same username, you still may run into some problems (but these can be remedied; keep reading). When I first set out to get sync working, I saw some funky behavior. For example, I’d create the symlink on machine one, run a couple of tests on machine one to make sure it was working, and then run some tests on machine two (which immediately showed the symlink in its Dropbox folder, as it should).
At some point during this process, the symlink on machine one would break, and the LocalDrafts folder (the MarsEdit folder I was trying to sync) would be copied into the Dropbox folder and the symlink removed entirely. You can appreciate the problem: both machines were now synced, but MarsEdit could no longer see the synced folder because it existed outside of the hard-coded directory used by the application.
To get around this, I thought to create the symlinks on both machines semi-simultaneously, in the hope that some contention rule would let them stand on their own (i.e., machine one wouldn’t ‘cause’ the symlink to be created on machine two, and therefore wouldn’t set into motion the problem just described).
Well, my hunch was correct — creating the symlinks at the same time does the trick. Over the last couple of months I’ve had zero problems with the setup; the symlinks on both machines have persisted without issue.
Finally, the actual solution
Remember that Dropbox syncs only what’s in its folder, and so the symbolic link must be placed there. To do this, simply navigate, on every machine you want synced, to ~/Dropbox/, and execute the following command (simultaneously on all machines):
ln -s ~/Library/Application Support/MarsEdit/LocalDrafts marsdrafts
That’s it. Realize that marsdrafts is the new directory entry that will be created; you can name this whatever you want. Keep in mind that if you have MarsEdit open on two machines simultaneously, and make changes to a draft on machine one, those changes may not show up on machine two until you restart MarsEdit on machine two (which will cause the application to re-read the LocalDrafts folder).
OmniFocus lets you specify where you want to store your database file, and so it’s trivial to get it working with Dropbox (i.e., simply tell OmniFocus to store the database file in the Dropbox folder).
However, there is one caveat. You’re going to want to quit OmniFocus on machine one before firing it up on machine two, else you’ll likely run into the file being locked by one instance of the application, which can result in some weird (and maybe fatal?) contention issues.
I note that this method, and the issues that come with it, have been obviated by the sync-capable OmniFocus v1.1 (currently in pre-release). While on the topic, and despite my grumblings about the price, OmniFocus for the iPhone is very nice.
These methods obviously may work with any other application you’d like to sync across multiple machines. However, you should remain cognizant that certain applications may have read/write mechanisms that preclude these particular approaches; as ever, backup your data before experimenting.