Last night i migrated mailservers for my private domains. It was a pretty straightforward process. First of all I used these guides on the internet to setup a mailserver with virtual mailboxes, DKIM, DMARC, AMAVIS, Spamassassin and so on.
- https://www.linuxbabe.com/mail-server/setting-up-dkim-and-spf
- https://www.linuxbabe.com/mail-server/create-dmarc-record
- https://help.ubuntu.com/community/PostfixCompleteVirtualMailSystemHowto
- https://www.linuxbabe.com/mail-server/postfixadmin-ubuntu
- https://www.linuxbabe.com/mail-server/postfix-amavis-spamassassin-clamav-ubuntu
Then I had to rsync the mail over to the new server rsync -azv -e 'ssh -p22' --progress /var/vmail/<domain>/<account>/ root@<to-server>:/var/vmail/<domain>/<account>/Maildir
for all <domain>
s and <account>
s. I ran this on the old server.
And I ran this in cron every 10 minutes while fixing DNS. The way I did it in DNS was to setup the new sever as a backup MX, and wait for the DNS change to propagate out to the internet.
When the change had propagated I stopped postfix and dovecot on the old server, and stopped the rsync job in cron. I ignored the risk that I might loose a couple of mail messages. It should not happen, but anyways.
After a short while the mails started arriving on the new server, but the old server is not shut down, since there might be stuff there which I might want to keep.