|
Convert from UW IMAP to Courier IMAP
This page describes briefly how to convert a mailbox from UW IMAP (mbox) to Courier IMAP (Maildir).
Why may you want do that?
I have used UW IMAP now for several years and it served me well. But now the time has come that it just does not meet my requirements any more. Especially the speed is not at the level I need it. I like IMAP. I have several clients on my workstation, notebook, in university, on my Palm handheld and even on my cell phone! Of course there is also a web interface (I use Squirrel Mail). But with the Mbox format and UW IMAP accessing my inbox and logging in in the first place where horrible slow (> 30 secs with a usual client, > 1 minute in the webinterface, about 3000 mails in inbox, archiving yearly). I got used to wait for the client, start the client after bootup and do something else like reading /. for a minute. I tried to boost up the web interface speed using an IMAP proxy that holds the connections up.
But this all felt bad. I already installed Courier at a customer's site for several thousand mail boxes. And a couple of months ago I installed Courier on a friend's machine. He was pretty happy with Courier so I gave it a try - and it was the right decision.
What is being converted?
I have a couple of mailboxes that I needed to convert, nothing big. This is not meant for mass imports! I wrote a script for the mentioned customer to do that, so if you need stuff like that feel free to contact me. This procedure is meant to be done "semi by hand", meaning that you will start scripts for specific mail boxes or folders "by hand" on the command line. This will not import a whole domain automatically or stuff like that.
Requirements
You need a server running the old UW IMAP with the old mail boxes and a new server running Courier IMAP. You can run both on the same machine on different ports, this is no problem and this is what I did. I have used two tools for conversion: imapsync (http://freshmeat.net/projects/imapsync/) and mb2md (http://batleth.sapienti-sat.org/projects/mb2md/). Both are written in Perl, so you will need a running Perl installation. They need some extra modules, refer to their documentation for what that is.
Which tool to use
I like imapsync better than mb2md since it imports all internal dates, keywords and stuff. Also since courier creates all the messages it updates its index files as needed. So this is the preferred way. But imapsync is a lot slower than mb2md. So I ended up importing all personal mails and mailinglists using imapsync and the real fat boxes like the Spam box (yes, I even imported that for statistics...) and some system generated mails via mb2sd.
Import
A basic mailbox import looks like this:
while ! ./imapsync --subscribe --subscribed
--host1 localhost --port1 143
--host2 localhost --port2 2143
--user1 fromuser --password1 frompass
--user2 touser --password2 topass
--noauthmd5
--prefix INBOX. -sep1 / -sep2 .
--syncinternaldates --regextrans2 "s/^mail\.//"
; do echo not done ; done
This is one command line. It will convert the mailbox of the user fromuser from the old server running on localhost port 143 to the new server running on localhost on port 2143. I have disabled the MD5 authentication since I did not use it. I used the recommendation for the UW IMAP to use "mail/" as the prefix. Set it as you would set it in your mail client. Courier uses "INBOX." as its prefix. The path separators are also different. UW uses "/" while Courier uses a dot. The regular expression is used to remove the prefix of the old mailbox. imapsync does not do that...
I patched imapsync a bit to make it a bit more chatty and to fix a slight annoyance with my regex. You can find it at http://www.niemueller.de/software/patches/imapsync.patch.
For the big boxes I used the following mb2md call:
perl mb2md-3.20.pl -s mail/Spam/Filtered -d Maildir/.Spam.Filtered/
I think you get the idea.
Conclusion
The whole conversion took about two weeks. Imapsync ran most of the time... Also think about changing your filters and stuff. For example you have to edit your .procmailrc to reflect the new paths to mailboxes and they must end with a slash to be recognized as maildirs.
|
|