Migrate mail from one server to another


I have one server that crashed, but the HDD is still intact, I have built another UCS / OX Appsuite installation and was wondering if there was an easy (“easy”) way to move mail from one to another without corrupting anything?


Cyrus and Dovecot both use (their interpretation of) a Maildir directory layout. It can simply be copied.

  • install the OX app on the new server
  • shut down the IMAP servers on both sides
  • use the same server on both sides (Cyrus or Dovecot) - verify with dpkg -l ‘cyrus or dpkg -l ‘dovecot
  • create the same user accounts with the same email adresses (maybe that’s a given, if the domain is still intact and this was not a dc master)
  • possibly modify “mailHomeServer” to point to the new server, if it has a different fqdn
  • test if everything works - test IMAP access for you users to their new, empty accounts.

Now you should have the same directories (except mails of cause) on both sides - verify it!
With Cyrus they are:

/var/lib/cyrus/ /var/spool/cyrus/
with Dovecot they are:

/var/lib/dovecot/ /var/spool/dovecot/

Then make a backup of the unused directories first:

rsync -av /var/lib/cyrus/ /var/lib/cyrus.bak/ rsync -av /var/spool/cyrus/ /var/spool/cyrus.bak/
and then use:

rsync -av --delete -n <OLD HDD>/var/lib/cyrus/ <host:>/var/lib/cyrus/ rsync -av --delete -n <OLD HDD>/var/spool/cyrus/ <host:>/var/spool/cyrus/
to copy the complete directory tree over to the other side. The “-n” makes it a dry-run. Remove it to actually copy to and delete at the target.

When you start the IMAP server, all should work as expected.