Maildir to Communigate mbox Mass Conversion Utility --------------------------------------------------- Scenario: The company is migrating mail services from an outsourced company to a local server running Communigate. We are told we will receive all 30 gigs of the user's mail in maildir format on a DLT. We would like to convert all of this maildir mail to mbox format because we find it simpler to maintain. Solution: Given a collection of maildirs, this program will proceed to convert the mail to mbox format to be stored within the Communigate user directories. It relies on a patched maildir2mbox program which is originally from the qmail source. The patch adds the ability to process many maildirs at once and speeds up bulk conversions greatly. This perl script will organize and spawn a number of these conversion processes to finish the task as fast as possible. Disclaimer ---------- Use this program at your own risk. It suited my needs, but I suggest you look over all of the source so you know what it is doing. I strongly suggest you experiment on COPIES of your /var/Communigate tree until everything looks ok. Requirements ------------ PERL, qmail-1.03 source code, Communigate (though you may be able to modify this for other systems) Setup ----- Grab the qmail-1.03 source code. You can get a copy from: http://www.bigfoot.com/~valankar/convert_mail/qmail-1.03.tar.gz Apply qmail.patch: cd qmail-1.03 patch < /path/to/qmail.patch Or alternatively, just copy maildir2mbox.c over the one in the qmail source. Configure and compile qmail, but don't install it. Copy the maildir2mbox binary to /usr/local/bin/maildir2mbox_file with proper permissions (execute). Modify the following variables in convert_mail.pl to suit your needs: $NUM_PROCESSES - The number of conversion processes to run. 3 is good $PROCESS_INBOX - Set to 1 if you want to import the INBOX. WARNING - Importing the inbox on a running system can cause corruption if anything else is writing to the inbox (such as incoming mail, etc). I suggest importing inboxes via other means, like the MovePOPMail that Communigate comes with. If you really want the inbox conversion, shut down Communigate before using this. We were able to import all non-inbox folders on a live running system without problems. However, you may want to shutdown Communigate before doing ANY import to be safe. Running ------- Say for example you have a domain in Communigate called mydomain.com. The users must already exist in the domain. In a directory 'impmail' you have all of the maildir mails in the following format: impmail/..../username/Inbox impmail/..../username/Other_Folder and so on "...." can be any number of subdirectories. The final directory and username chosen depends upon the existance of ..../username/Inbox. Only when this exists is it considered a valid user maildir. This directory traversing lets you process a whole directory tree with maildirs anywhere beneath. To import into the standard location: ./convert_mail.pl `pwd`/impmail /var/CommuniGate/Domains/mydomain.com or alternatively if you already have an up to date Index.data in the current directory: ./convert_mail.pl `pwd`/impmail /var/CommuniGate/Domains/mydomain.com Index.data If you do not specify the index, it will be created in the current directory as Index.data.generated. Note that `pwd` is needed above because the full path is required. You can also restrict to only a certain user, by adding '-u username' to the end of the command line. BUGS ---- Please report them to valankar@bigfoot.com