If you are like me, relying on good old MH/NMH and mh-e and exmh to do your mail, then you'll know that there are few decent solutions for synchronizing your MH boxes between computers.

Sure, you could use mailsync to sync MH-to-IMAP on one computer (and inversely on your other computer), but that detour is not very nice.

I've also looked at syncmaildir, which syncs maildir-to-maildir, hence not directly useful. But its mddiff tool which does most of the interesting work is easily modifiable to deal with MH boxes instead of maildir, and I did try that. Unfortunately syncmaildir's messy mix of c+shell+lua is pretty ugly, and mddiff's heuristics aren't quite up to scratch (it's one-and-a-half-directional at best..).

Net result: I decided to write my own direct, bi-directional MH-to-MH sync tool in Perl, which is available here: feel free to experiment, mangle, modify and/or simply use it. Feedback very welcome.

mhsync needs to be present on both machines, and you need both ssh and sshfs, ideally with key auth and/or ssh-agent up and running (or you'll have to enter your credentials twice for each sync run).

When I say bi-directional, I mean it: You should be able to work with both mailboxes at will and mhsync will try very hard to get both mailboxes into a consistent, sensible state - but as it lacks human intelligence it won't always guess right which conflicting mailbox modifications to pursue. Also, MH has no locking: don't run mhsync concurrently with other major mailbox editing (delivery of new mail is fine, however).

So, no guarantees. mhsync may very well renumber mails to resolve name clashes. It should never ever overwrite mails, but might give you duplicates. It will not ever remove mails unless you give it the -X option (and then only if it's seen the mail as properly in sync in the past but gone on one side now). In any situation that it doesn't understand it'll print out the problem status on STDERR. It's got a dry-run mode (-n) and three levels of verbosity (-d N: 0 = show unresolvables only, 1 = info about high-level decisions, 2 = which file ops are made.

Let me know what you think.

Update (Sat 03.08.2019 14:40):

i've updated my trusty old mhsync tool to also handle multi-way syncing, e.g. one main box and two different laptops.

the tool remains available here.

[ published on Tue 29.11.2011 16:20 | filed in mystuff | ]
Debian Silver Server
© Alexander Zangerl