[Dovecot] sdbox to mdbox

Stan Hoeppner stan at hardwarefreak.com
Sat Dec 25 01:57:35 EET 2010


Joan Moreau put forth on 12/24/2010 5:41 PM:

> 1 - plan to have all the new emails in a different folder (say
> "/data/mail2" )
> 2 - make a script that go through all users & domains
> 3 - for each user (and therefore dbox folder), run "dsync -o
> mail_location=sdbox:/data/mail/%d/%n mirror mdbox:/data/mail2/%d/%n"
> (where %d and %n are updated correctly for each user)
> 4 - move /data/mail to /data/mailold and move /data/mail2 /data/mail

You don't have to move the mail "back".

> 5 - update dovecot.conf with "mail_location = mdbox:/data/mail/%d/%n"

Simply change the mail location to the new directory in dovecot.conf.
After you've confirmed all the users' mail is safely in the new location
you can delete all the old mail folders/structure.

> 6 - Only then, restart dovecot in production ?

You can perform all of this without stopping Dovecot.  IMAP commands are
used for the mirror operation to the new directory/mailboxes not some
direct file manipulation that requires the mailboxes be offline.

Shutting down dovecot simply makes sure you don't miss new mail that's
written by users or your MTA (new deliveries) while the mirror operation
is running (which can take a LONG time).  If you do it live, you simply
have to make a second run, which will be MUCH faster due to fewer "new"
mails to mirror.  Think of how rsync works--only new files are copied.
So the seconds run will be quick.  Immediately after the second run,
stop dovecot, change the mail location in dovecot.conf to the new
directory with the mdbox files and start dovecot.  Or, better, stop
dovecot before the 2nd mirror run, run the mirror op, change
dovecot.conf with new mail location, start dovecot.  Down time during
the 2nd run should/will be minimal.

> ISn't there a way to do that keeping dovecot running ?

Yes, see above.

-- 
Stan


More information about the dovecot mailing list