I've been eyeing Mailcow for a while since it's use of Docker should ease the maintenance and update burden (you iRedMail users know what I'm talking about lol) and bring a better UI and user experience with it's admin panel. Here are some notes that I took from my migration in case it helps anyone else out.
I setup a Mailcow instance on another server so I could keep iRedMail operating during the migration. After it was completed, I used Mailcow's backup and restore feature to move it to my original server.
Migrating has three main parts, mail, contacts and calendars, and DKIM. There's also some configuration which I'll touch on too.
Prior to this, you should have added your email domain to Mailcow in order to setup the accounts.
Mailcow comes with a tool for syncing over a mailbox through IMAP. It looked like there might be some way to migrate with a Dovecot command but this just ended up being simpler.
For every single user, add an account for them on Mailcow. Then, reset their password on iRedAdmin (or just use the current password if you have it) and add a sync rule for them with it. It takes a few minutes to sync so you can let this run while you take care of the next steps.
Prior to this, you need to have an account in Mailcow for every user you are migrating over.
SOGo also has it's own migration tool. On the iRedMail server, run
su - sogo -s '/bin/bash' -c '/usr/sbin/sogo-tool backup /tmp/sogobkup email@example.com'
for every single user. This will collect all of their user data in a folder in /tmp/sogo/
.
After this, we need to copy their data into the SOGo Mailcow Docker container. It's easiest to just put it in data/conf/sogo
, which will be
/opt/mailcow-dockerized/data/conf/sogo
for most of you. Note that you need to move the folder, so the final path should be
/opt/mailcow-dockerized/data/conf/sogo/sogobkup
.
Next, open a shell inside the SOGo container with sudo docker compose exec sogo-mailcow /bin/bash
, then su -s /bin/bash sogo
to swap to the SOGo user.
Finally, to restore run /usr/sbin/sogo-tool restore -f ALL /etc/sogo/sogobkup email@example.com
for each user.
Prior to this, you need each of your mail domains added to Mailcow.
Thie one's the easiest. It's best to just adopt your current DKIM keys so you don't have to change your DNS records. To add each key, go to the Mailcow admin configuation page, go to Configuration -> ARC/DKIM keys -> Import private key. I don't remember if DKIM key location was standardized, but mine were in /var/lib/dkim
on the iRedMail server. You can just cat
the contents of each key and copy it into the Mailcow UI.
After this, your Mailcow instance should be good to move over!
Configuration is going to be more individual, so I'll just link a few things that helped me.
I put Mailcow behind an Nginx reverse-proxy, the docs for that are here https://docs.mailcow.email/post_installation/firststeps-rp/#nginx
Mailcow's LetsEncrypt was too much of a headache to work with so I ended up just acquiring the keys myself with certbot on the host. This issue on Mailcow should provide some help. I'll also post an example override too.
Finally, I used another server to host a ClamAV server. Here's another helpful issue. I setup a VPN between the two servers using tinc using this guide as a reference. I also used this Docker image. You might have to open the port to the VPN if you are using UFW, the command I used was sudo ufw allow in on tun0 to any port 3310
.
Just wanted to say thank you - this saved me a lot of time today! <3