So I have finally come over to the light and decided that Maildir is a better format than mbox (or mbx or whatever else) for UNIX mailboxes.
For performance reasons and because I want to scale mailservers using NFS (NAS backend) and Maildir doesnt have locking issues, I have decided to switch to Maildir.
So If I were to have several mailservers loaded down with users that have existing IMAP access with mbox files how would I convert them?
Well it turns out many utilities exist to do this conversion. The most full featured and well tested that I could find is mb2md.pl. However, by design, it is intended to be run AS THE USER YOU ARE CONVERTING. That means it appears its intended to run one user at a time, logged in as that user.
Since I didnt have time for that I decided I would write a wrapper to mb2md that can do the conversion for an entire system using a copy of the passwd file (a copy with system and other accounts that dont need conversion removed of course).
So I wrote mb2md_wrapper. Its basically a copy of mb2md 3.10 that has been modifed to use special ENV variables to decide what user and directory to perform conversion on. It includes another script mb2md_wrapper that then wraps and calls mb2md while reading in all the user details and setting the required environment variables.
Its worked in PRELIMINARY FORM for me, its definitely ALPHA stuff, use at your own risk!!! I thought someone else *might* find it useful so thats why its here.
If you have suggestions, updates, etc, please let me know. If this script changes as I go (and use it more and more) then I will post updates here.
Comments
RE: Converting mbox to maildir and a wrapper for mb2md.pl
Hey, is the applicable if you want to switch from UW IMAP to Cyrus? I noticed that Fedora doesn't even ship with UW and I had to hack it in. I would like to migrate my 6 gigs of email to cyrus, but Im not familiar at all with it -- especially the whole "each user doesn't have a mailbox thing".
RE: Converting mbox to maildir and a wrapper for mb2md.pl
Yes the default cyrus format is maildir. If you have an mbox file and want to convert it, this is the sort of thing you want, if you want to do it for just one file you simply need the standard "mb2md" thing.
RE: Converting mbox to maildir and a wrapper for mb2md.pl
excellent script...have used it to convert mboxes of our office mail server....the acid test will be when i convert our production server over...nearly 4000 users...will tell you what happens.....
RE: Converting mbox to maildir and a wrapper for mb2md.pl
Glad it might possibly help, let me know please if you make mods or such and I will post them here. Thanks.
Suggested change to wrapper
Checking if this script will help us migrate to Maildir at the moment. Thanks in advance!
A suggested change for the wrapper:
It doesn't work if in the passwd file there also is the fullname of the user (containing spaces). E.g.: user.company.nl:x:510:502:Firstname Lastname:/home/company/homes/user:/bin/bash
Replace:
for PASSWD_LINE in `more "$PASSWD_COPY"`
...
exit 0
With:
exec 3<&0
exec 0<$PASSWD_COPY
while read PASSWD_LINE
...
exec 0<&3
exit 0