Convert from mbox to Maildir

Joseph Tam jtam.home at gmail.com
Fri Oct 13 22:39:29 EEST 2017


Nikolai Lusan <nikolai at lusan.id.au> writes:

>> Just went through this one recently using CentOS with SendMail, Procmail
>> and IMAP conversion from mbox to Maildir - I needed to make sure I could
>> run both formats while I migrated users one-by-one.
>
> When I have migrated solutions from mbox to maildir (I have done more than
> one) I found it easier to get a mail client to do the hard work for me (if
> you're on a LAN with the server it's faster). I created new usernames with
> maildir as their base, and copied the folder over.

Reading over David's and various schemes, the tricky part is consistency:
avoiding race conditions where you have the user manipulating their
mailboxes and your MTA/LDA delivering mail, while simultaneously doing
mbox->Maildir conversion.

To guarantee consistency, it's necessary to lock out other avenues of
mbox changes while the conversion takes place.  Otherwise, you'll have the
situation where mail can get duplicated, or worse, deleted.  For example,
think of this sequence: convert B, user moves message A->B, convert A.

I think the safest is method is

 	1) Deny the user access to IMAP/POP: deny
 		userdb/passdb, or lock their password
 		and flush their auth cache entry.
 	2) TEMPFAIL MTA delivery to user during conversion
 	3) Kick the user
 	4) Do the conversion
 	5) Undo 1+2

If you have a smart conversion script (one that recognizes changes and
only do delta updates) you can greatly speed up step 4 and minimize
outage time.

 	0) Do an initial conversion that will do the bulk of the work
 	but does not guranatee consistency.

Joseph Tam <jtam.home at gmail.com>


More information about the dovecot mailing list