Converting mbox to maildir and a wrapper for mb2md.pl
Submitted by charlie.collins on Tue, 07/15/2003 - 10:26
Tagged:
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
RE: Converting mbox to maildir and a wrapper for mb2md.pl
RE: Converting mbox to maildir and a wrapper for mb2md.pl
RE: Converting mbox to maildir and a wrapper for mb2md.pl
Suggested change to wrapper
Procmail Users
chown $USER_NAME:$USER_NAME /home/$USER_NAME/Maildir/ chown $USER_NAME:$USER_NAME /home/$USER_NAME/Maildir/* -Rafter the call to mb2md as the wrapper scripted called everything correctly, but I just passed "-m" to mb2md which created the folders as root:root, this was becuase I ran the script as root. If you don't do this with procmailDROPPRIVS=yes, then procmail can't drop the messages into the maildir layout.