Scribblin.gs
a blob   Software

MigrateMail

Migratemail is a tool for migrating mail (both current and archived) from mbox-based systems to maildir-based ones. Several tools already exist for converting an mbox-format INBOX into a Maildir (see, for example, mbox2maildir in patches below). However, on a live mail system, migration to a maildir system requires more than simply converting inboxes; it also involves migrating of users' active mail folders (such as those for storing sent and saved mail). Unfortunately, converting mbox folders (other than an INBOX) to maildir format for use with, say, the courier mail server, is not simply a question of making one maildir per old mailbox because the structure of the maildir format is such that each user has a single maildir within which are stored all folders. Migratemail takes an INBOX and hierarchy of mbox-folders, and migrates them to a single, properly formatted Maildir.

Maildir performs the following operations: first, it generates a Maildir for the user by copying the contents of their old Inbox. Then it looks recursively through a directory structure (given as command-line argument), finding things that look like mboxes, and creates maildirfolders for them within the Maildir. The original hierarchy, if existent, is kept, so that messages in an mbox whose path is <old-homepath>/mail/sysadmin/boredom will be put in a Maildir folder called .mail.sysadmin.boredom within the user's Maildir. It is used as follows:

migratemail.pl 
  <inbox-path> <old-homepath> <new-homepath>
  <user> <group>

where <inbox-path> is the path to the OLD mbox-style INBOX
      <old-homepath> is a directory full of mboxes
         or a directory of directories of mboxes...
      <new-homepath> is the directory within which Maildir will be created
      <user> will have Maildir chowned to them
      <group> will have Maildir chgrped to them

The program requires Bruce Guenter's mbox2maildir program (or my patched version of it - see below) and GNU touch to function correctly. It expects to find mbox2maildir at /usr/sbin/mbox2maildir and GNU touch at /usr/bin/touch. If these assumptions are incorrect, open migratemail in your favourite editor and change the first two lines of the script as required. No other changes should be necessary. Final note: although probably obvious, it should be noted that the user running migratemail needs write permissions to <new-homepath> and read permissions to <old-homepath> and <inbox-path>

MigrateMail is released under the terms of the GNU General Public Licence Version 2.

Download MigrateMail