[Dovecot] Migrating mail from mbox to maildir using dovecot

Egbert Jan van den Bussche egbert at vandenbussche.nl
Tue Sep 14 22:24:59 EEST 2010


Op 14-9-2010 17:51, Donny Brooks schreef:

> I think I will have to stay with the 1.x branch since we have to stick to using approved rpm's (internal policy) and fedora 13 does not have a 2.x branch that I see yet. So maildir it is for now.
> I see my error on the inbox not getting the new mail. That was one of those "all nighter" errors that I just plain missed due to lack of sleep. I forgot to point postfix to the proper place to deliver the mail.
> So once I setup postfix to deliver the mail properly and the dovecot convert plugin is setup, is there a way to gradually migrate the users so I don't kill the server? We have about 220GB or so of mail between about 160+/- users. What would be the best way to migrate it all to maildir?
>
In my test to convert a mbox situation (sendmail) to Dovecot, I used 
script similar to that below. The conversion is done with the mb2md.pl 
script and all takes place when a user logs in. The fact that $@ is 
destroyed by the awk does not seem to harm. YMMV!

I used the hooks provided in the dovecot config file (thanks Timo) where 
you can call a script instead of the IMAP exec. Details are in the 1.x 
dovecot wiki.

HTH
Egbert Jan (NL)
----
#!/bin/sh
#
# split $USER in User and Domain

var=$(echo $USER | awk -F"@" '{print $1,$2}')
set -- $var

#
# If /var/mail/<user> does not exist : skip to exec
#
if [ -f /var/mail/$1 ]
then
    set > /etc/dovecot/dovecot-$1
    #/etc/dovecot/mb2md.pl -S -W -s /var/mail/egbert -d $HOME
    #chown vmail:vmail $HOME/cur/*
    mv /var/mail/$1 /var/mail/$1-converted
fi
exec /usr/lib/dovecot/imap "$@"
----


More information about the dovecot mailing list