I needed to move my mail system based on dovecot / postfix from one host to another preserving all mailboxes and also all imap UUIDs, so that imap clients can still identify mails.
There are some tools that come with dovecot but every how to that google returns for the problem seems much too complicated for that simple problem.
When you look at the man page of doveadm or dsync you know why: both tools have an overwhelming number of options.
After some reading and trying, is it basically use dsync for backup and restore and – also important – create same user accounts on both machines source and destination.
Then it goes like this:
- create a world writeable tmpdir to dump the mailbox to e.g. /tmp/dump: mkdir /tmp/dump && chmod a+w /tmp/dump
- use dsync to dump: dsync -o plugin/quota= -f -u <email> backup maildir:/tmp/dump
- compress with tar preseving time / permissions: tar cvzf dump.tgz /tmp/dump/ –atime-preserve –preserve-permissions
- copy the tar archive to new machine: scp dump.tgz user@target:
- decompress into a world readable directory e.g. again /tmp/dump
- If the mail account was touched already remove the complete mail directory (path depends on your setup, in most cases somewhere below /var/vmail/… or /var/mail/….)
- Restore the mailbox with: dsync -R -f -u <email> backup maildir:/tmp/dump/
That’s basically it. Just repeat for alle mailboxes you need to move and your done. Also a very fast and portable way to backup mailboxes.
Surprisingly this simple 7 step approach is not mentioned in any FAQ or manual I read, so here we are: just use it and your done.
7 Antworten auf Migrating dovecot mailboxes from one host to another