Migrating dovecot mailboxes from one host to another

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:

  1. create a world writeable tmpdir to dump the mailbox to e.g. /tmp/dump: mkdir /tmp/dump && chmod a+w /tmp/dump
  2. use dsync to dump: dsync -o plugin/quota= -f -u <email> backup maildir:/tmp/dump
  3. compress with tar preseving time / permissions: tar cvzf dump.tgz /tmp/dump/ –atime-preserve –preserve-permissions
  4. copy the tar archive to new machine: scp dump.tgz user@target:
  5. decompress into a world readable directory e.g. again /tmp/dump
  6. 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/….)
  7. 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.

Dieser Beitrag wurde unter Allgemein, Misc veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Eine Antwort auf Migrating dovecot mailboxes from one host to another

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *