Based on Debian 11 "Bullseye" environment.
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.)
Prerequisites
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...
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 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
The doveadm commands for step 2 and 5 are explained below.
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 user1@example.jp remote:new-server.example.jp
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.
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 user1@example.jp remote:new-server.example.jp
It looks useful for the initial migration, but the official document discourages using this instead of the backup command.
2021-09-23
2021-10-06