💾 Archived View for perso.pw › blog › articles › dsync.gmi captured on 2023-09-28 at 16:46:05. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-05-24)

➡️ Next capture (2024-03-21)

-=-=-=-=-=-=-

Convert mailbox to maildir with dovecot

on Mastodon

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

modify dovecot/conf.d/10-mail.conf, replace the first line

mail_location = mbox:~/mail:INBOX=/var/mail/%u # BEFORE

mail_location = maildir:~/maildir # AFTER

# service dovecot restart

# dsync -u solene mirror mbox:~/mail/:INBOX=~/mail/inbox

# service smtpd start