convert mdbox to maildir

Steve Litt slitt at troubleshooters.com
Sun Aug 14 16:24:59 UTC 2022


On Sat, 2022-08-13 at 18:36 +0200, lutz.niederer at gmx.net wrote:
> 
> The real problem is that we must not use the running, old dovecot installation. 
> So we are not able to connect to the old server, pull all folders and mails and
> create a new maildir structure.  Currently, we can't do anything against it.  What
> we get are the users' mdbox files.

Why not? Is the old server broken beyond repair? If not, is there an actual reason
behind, or is it just a arbitrary decision capable of being swayed by facts? Is the
customer willing to pay for the large increase in time to rebuild the whole thing?

Will they at least let you rsync the old server's entire mdbox structure to a
machine where you can do your conversion? I don't know, to me their act of giving
you some files and saying "it's your problem now" seems arbitrary, and you should
charge them a lot of money.


> 
> Is there any way to convert mdbox files and structures to maildir directly from
> filesystem?
> Or do we have to build a copy of the old machine (dovecot only, or -maybe better-
> a vm) and then use doveadm backup?
> Or is it ok to just set up the completely new installation, set mail_location to
> where the new Maildirs will be, like maildir:~/Maildir and then run something like
> doveadm backup mdbox:/tmp/$user/mdbox -u $user?  Will this transfer all mails and
> folders or do we have to keep an eye on some specific things?

All I know about mdbox comes from this document:
https://doc.dovecot.org/admin_manual/mailbox_formats/dbox/

Quoting a specific sentence: "One of the main reasons for dbox’s high performance is
that it uses Dovecot’s index files as the only storage for message flags and
keywords, so the indexes don’t have to be “synchronized”. Dovecot trusts that
they’re always up-to-date (unless it sees that something is clearly broken). This
also means that you must not lose the dbox index files, as they can’t be regenerated
without data loss."

The quote says *dbox*, but it's in a section devoted to both dbox and mdbox, so I'm
thinking it might be true of both. Have they given you the index files? If not, it
sounds to me like any regeneration would be an approximation at best.

Do you have a way of accurately putting together the directory structure of the
former mdbox system?

My experience 10 years ago converting about a quarter million kmail emails to
Dovecot Maildir is it takes about an hour to transfer between 25,000 and 50,000
emails, but of course that was on a much more anemic machine than I have today. I'd
guess that if you have both databases on the same machine, the way I did ten years
ago, the process will go pretty fast. Here's a count of my Dovecot Maildir today:

[root at mydesk Maildir]# du -hs
16G     .
[root at mydesk Maildir]# find . | wc -l
734906
[root at mydesk Maildir]#

I don't know much about your particular situation, but it seems to me like the
majority of your problem isn't technical.

SteveT


More information about the dovecot mailing list