So I’ve just migrated my mail server recently. I was initially using iRedMail but needed to move it to another server. The problem though is that the destination server already had MySQL and Nginx as a web server. I just wasn’t comfortable running a script that has a chance to break what I’ve currently setup. I also didn’t want to take the route of creating my own email server from cratch. I’ve already did it in the past and it was okay but it was a hassle to maintain. So like anyone else I’ve jumped to Google to search for any free open source email server. Lucky for me I was able to find Mailcow relatively quickly. It’s open source and uses popular open source software for the email server components (MTA, Database, WebServer, etc.). The great thing about it though is that its dockerized which would not interfere with what is currently installed in the destination server.

So after installing Mailcow on the destination server and migrating accounts – I’ve only had quite a few accounts to migrate so I did it manually. Now comes the problem of migrating the emails from the old server to the new one. Good thing that dovecot already handles this kind of thing by providing, doveadm sync , a tool that enables you to move/backup mails from and/or to accounts.So the plan is using the doveadm sync I’ll backup the mails from the old server and restore them to the new/destination server. You’ll need to run this command on the old/source email server either in root or theĀ dovecot user.

This command will create a the backup in /backup/directory folder so make sure that the user has write access on that path. You can run this command for every accounts and it shouldn’t have any conflict on the previous runs.

After making sure that all accounts are now backed up we would now need to transfer these to the new/destination server. You can do that in any way you want but what I did was to create a tar.gz of the backup then transfer it using scp to the new server.

Then on the new/destination server you would just need to run this command for every account. Again this command should be run as either root or the dovecot user.