Title: Convert mailbox to maildir with dovecot | |
Author: Solène | |
Date: 17 January 2017 | |
Tags: unix email | |
Description: | |
I have been using mbox format for a few years on my personal mail | |
server. For those who don't know what mbox is, it consists of only one | |
file per folder you have on your mail client, each file containing all | |
the mails of the corresponding folder. It's extremely ineficient when | |
you backup the mail directory because it must copy everything each | |
time. Also, it reduces the system cache possibility of the server | |
because if you have folders with lots of mails with attachments, it | |
may not be cached. | |
Instead, I switched to maildir, which is a format where every mail is | |
a regular file on the file system. This takes a lot of inodes but at | |
least, it's easier to backup or to deal with it for analysis. | |
Here how to switch from mbox to maildir with a dovecot tool. | |
# dsync -u solene mirror mbox:~/mail/:INBOX=~/mail/inbox | |
That's all ! In this case, my mbox folder was **~/mail/** and my INBOX | |
file was **~/mail/inbox**. It tooks me some time to find where my | |
INBOX really was, at first I tried a few thing that didn't work and | |
tried a perl convert tool named **mb2md.pl** which has been able to | |
extract some stuff but a lot of mails were broken. So I have been | |
going back getting dsync working. | |
If you want to migrate, the whole process looks like: | |
# service smtpd stop | |
mail_location = mbox:~/mail:INBOX=/var/mail/%u # BEFORE | |
mail_location = maildir:~/maildir # AFTER | |
# dsync -u solene mirror mbox:~/mail/:INBOX=~/mail/inbox | |
# service smtpd start | |