[Dovecot] sdbox to mdbox
sf.rique at gmail.com
Sat Dec 25 02:43:08 EET 2010
Gonna start over and try to be more simply.
On Fri, Dec 24, 2010 at 9:57 PM, Stan Hoeppner <stan at hardwarefreak.com>wrote:
> 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" )
No. Do not need to do anything.
> > 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)
I did not, but you could!
> > 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.
You could, or use it from mysql.
> > 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.
I did with down time most part of it. But a few hundres i did live.
I have about 9k acount on my server.
> > ISn't there a way to do that keeping dovecot running ?
> Yes, see above.
As i will try to explain again!
First some info.
Dovecot can ether get this informations about gid and uid and mail location
from mysql using user_query. If the return of query is an result this will
be used, if it is null the conf file will be use.
I don't know if what i used is the best way, but it worked for me.
Right now, you can run this comand.
# dsync -v -u user at domain.com backup mdbox:/Converted/mail/user1/mdbox
And it will make exacly the same mail from user at domain.com in
but with only this, you can not do anything, becase dovecot for imap process
sees the location of mail in the conf file. and it still the other path.
This is why mysql with field "mail" goes. It tells dovecot that for that
user, the maillocation is /Converted/mail/user/mdbox
My user query tells me for each user. uid gid home and mail_location
Usualy my mail_location is maildir: ~/mail/ and home is
And for other users it uses mail_location from the file that is
I mean, like this i have total control what each user will have it for conf.
So once you have configured dovecot to user mysql you can run this steps.
1 - make the home of user unwriteble to dovecot.
2 - conver with dsync like this. # dsync -v -u user at domain.commdbox:~/mdbox/
5 - make mdbox:~/mdbox writible to dovecot
4 - Change mail location of this user in mysql ( before it was null, so
dovecot uses the file ) change it to mdbox:~/mdbox/
5 - Done. Now dovecot is already writing ( LDA ) and reading ( IMAP POP3 )
I guess it would be all
Still any questions ?
More information about the dovecot