access mail from old dovecot server backup
I want to access a few gigabytes of old mail that I have in an archived copy of a dovecot mail server's virtual mailbox files. I think it's an old version of dovecot's mdbox format? The server was built in 2008, and the archive taken in 2011. I'm guessing it might be mdbox 1.1.
I'm looking for suggestions of how to get this mail to the point where I can browse it with thunderbird.
It would be awesome if I could fire up an old version of dovecot to serve this mail via IMAP, possibly in a docker container. OR perhaps newer versions of dovecot can recognise the old format? Maybe a conversion tool of some sort?
Any help with identifying the format/version would be much appreciated. My files look like:
domain/
username/
dovecot.index
dovecot.index.cache
dovecot.index.log
dovecot.index.log.2
dovecot-keywords
dovecot-uidlist
maildirsize
subscriptions
cur/
1314076009.V55I369181M295175.mail.exmaple.com:2,STa
new/
tmp/
.folder/
dovecot.index
dovecot.index.cache
dovecot.index.log
dovecot-keywords
dovecot-uidlist
cur
new
tmp
.folder.subfolder/
dovecot.index
dovecot.index.cache
dovecot.index.log
dovecot-uidlist
cur
new
tmp
There's of course more folders, and more mail files, with flags in the file names as in the one that's there for an example.
You want to use Dovecot imapd to be able to copy the metadata. There is no need to deploy an older version, the current version (or the latest supported by your favourite distribution) will work with old backups just fine.
Your backup is a file-level copy of the Maildir++
format with some Dovecot-specific meta-information. Each file in the cur
/new
/tmp
directories contains one raw (Internet Message Format, see RFC5322) mail. The files called index
are just caches for faster lookup, the uidlist
and keywords
contain information not found elsewhere.
Even if you are not interested in keeping the original UID mappings (mostly interesting if you wanted to avoid downloading files already cached in a client that was connected at the time of the backup), there is one more thing that is not contained in the actual mail files & file names that you likely want to restore: The mapping of custom IMAP flags to their names. That mapping is contained in the file dovecot-keywords
and tells the mail sever which of the lower-case letters attached to the filename after the comma (a..z
) means which keyword ($Forwarded
, Charity
, Junk
, ..)
If you want each user to have access to specific backups, you'll need a fully fledged configuration with user db as well. If you just need to connect to everything with your IMAP client and use that to copy out what you need, you likely want to setup a Dovecot instance where all users are simultaneously visible in namespace
s, each with a mail_location=maildir:/domain/username
indicating the Maildir++
layout (as opposed to the fs
layout where subfolders are recursively arranged, not dot-separated paths).
Steps, roughly:
- install dovecot-imapd, ideally on a server that has no such server already running, to ease segregating your backup-restore operation and other mail
- create a system user and allow it to access those directories then configure it in Dovecot as the user to access mail with (
mail_uid=vmail
) - from the default dovecot configuration, add as many
namespace
blocks as you have maildir roots (folders which contain cur/new/tmp/.dotfolders) - add a passdb file to give you a user to connect to all this
- connect via your favourite mail client and drag'n'drop everything you want to preserve into one of your current mail accounts