Based on Debian 11 "Bullseye" environment.

Mail server migration

To migrate the emails from the old server to the new server, doveadm works well if Dovecot is working on both sides. It migrates (backups) mails, directories, and sieve scripts. (At first I didn't expect sieve scripts to be copied, but found the same scripts already placed at the new server when I was to manually copy them.)


  1. Dovecot is running on both sides
  2. SSH access as root is allowed in the new server
  3. Email users are defined as virtual users on /etc/dovecot/users

These prerequisites are not because of doveadm specification. This is to explain my case. Please refer to official command references for more details.
This article explains only about doveadm commands. Many steps to consider the mail server migration are too much to document here, so please find some other sites...


User list

The new server user list has to be set up before the migration. The easiest way is to copy the file /etc/dovecot/users.
Just the user list is enough. Dovecot will take care of making new directories as required. Even if there are existing emails and directories in the new server, they will be deleted during the initial backup process.

SSH as root

SSH login as root is normally not recommended for security reasons. Please use key pair style login, not the id and password style, and delete the key after you complete the process.
The old server will push the emails to the new server. You can use "doveadm -R" to reverse the destination, if you want to pull emails.


The steps

  1. Set the new server as the secondary MX
  2. Initial migrate (copy)
  3. Stop the new server mail service
  4. Delete the old server from the MX and set the new server as the primary MX
  5. Delta update from the old to the new

The doveadm commands for step 2 and 5 are explained below.

Initial migrate (copy)

The main process of data migration. All emails and directories (including empty directories) will be set up on the new server. Be aware that any existing data on the new server will be deleted during the process.

# doveadm backup -u

As the user is specified with "-u" parameter, this migrates one user data. If the new server has all the users of the old server, you can use "-A" to migrate all users data in the userdb. There are many users but have to be selective, use "-F filename" to specify the users to be migrated.

Delta update

If the server is very busy and there is a stream of emails coming in, there may be new emails received between steps 2 and 3, but the new server will start receiving just after step 3.
For the delta update, there is "-1" option for the sync command.

# doveadm sync -1 -u

It looks useful for the initial migration, but the official document discourages using this instead of the backup command.

Update History


  • Initial publishment


  • Add description about the sieve scripts