I’ve just released Larch, a Ruby application that syncs messages from one IMAP server to another quickly and safely. It’s smart enough not to copy messages that already exist on the destination and robust enough to deal with ornery or misbehaving servers.

A couple years ago I posted a quick and dirty script that did this. Larch is a much more mature tool that does essentially the same thing (only faster and more reliably).

Larch is particularly well-suited for copying email to, from, or between Gmail accounts. During its development, I used it to sync over 25,000 messages from a Dovecot IMAP server to Gmail.

To install Larch via RubyGems, run:

sudo gem install larch

Visit Larch’s GitHub page for usage information and other documentation.

Update: Larch now has a mailing list where you can post questions and comments and find answers to questions that have already been answered.

Comments

Hey there. I’ve been looking for a way to copy a large gmail account over to a google apps account, and this looks like exactly the tool I need. I haven’t worked with ruby much yet, but I was able to install ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32] and then install Larch using RubyGems. It appears to have installed correctly, but whenever I try and run it I get an error message:

C:\install\rgrove-larch>larch —from imaps://imap.gmail.com —from-user greg.bray@gmail.com —to imaps://imap.gmail.com —to-user greg.bray@oqmeasures.com —verbosity debug
Source password (imap.gmail.com):
Destination password (imap.gmail.com):
c:/ruby/lib/ruby/gems/1.8/gems/larch-1.0.0/bin/larch:87:in `trap’: unsupported signal SIGQUIT (ArgumentError)
from c:/ruby/lib/ruby/gems/1.8/gems/larch-1.0.0/bin/larch:87
from c:/ruby/lib/ruby/gems/1.8/gems/larch-1.0.0/bin/larch:86:in `each’
from c:/ruby/lib/ruby/gems/1.8/gems/larch-1.0.0/bin/larch:86
from c:/ruby/bin/larch:16:in `load’
from c:/ruby/bin/larch:16

I tried a bunch of different combinations of options but it always gives the same error. Any idea why it is failing?

Gravatar icon
Wednesday March 18, 2009 @ 05:27 PM (PDT)

Looks like Windows Ruby doesn’t like being asked to handle Unix signals. I haven’t tested Larch under Windows, so your best bet (if you have to use Windows) is to run it under Cygwin. I’ll wrap the signal handling code in a platform check for the next release.

Gravatar icon
Wednesday March 18, 2009 @ 08:06 PM (PDT)

This was perfect – it took a little doing (90 minutes or so) to get Ruby compiled and installed, and then RubyGems too, but then it ran overnight, hung in the middle, and when I restarted in the morning, it took a total of about four hours to do automagically what would have taken DAYS of personal attention.

Thank you!

Gravatar icon
Jeff
Thursday March 19, 2009 @ 08:34 AM (PDT)

Installing Cygwin+Ruby+RubyGems+Larch worked! For anyone else Interested in running Larch on Windows you should be able to follow these general instructions:

1. Install Cgwin, Ruby and RubyGems
NOTE: add the openssl and openssl dev to cygwin on install as it is needed later.
2. Install Ruby-zlib
3. Install Ruby OpenSSL
4. Install Larch and Enjoy!

So far it is working much better than imapsync, which was getting caught up on large attachments. Thanks again and keep up the great work!

Gravatar icon
Thursday March 19, 2009 @ 12:35 PM (PDT)
New comment

required, won't be displayed

optional

Don't type anything here unless you're an evil robot:


And especially don't type anything here:

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile.

Copyright © 2002-2010 Ryan Grove. All rights reserved.
Powered by Thoth.