Sunday 6 July 2008

Migrating between two qmail + vpopmail (qmailrocks) servers

This was my problem for today, how to migrate sound and safely from on old system running around 100 domains to a brand new configured qmail system. Both are running with the configuration suggested by www.qmailrocks.org and on a FreeBSD machine. So lets go:

  • First things stop the old qmail server to avoid loosing messages. Remember that you need to stop qmail from receiving any messages, and also stopping users from retrieving their email with pop3 or imap. The following commands would do it for you:
qmailctl stop
/usr/local/etc/rc.d/imap.sh stop
/usr/local/etc/rc.d/imaps.sh stop


  • After yo stopped qmail and the pop/imap daemons, you are able to start to transfer the vpopmail contents. Using rsync is a good idea, since that with it you can minimise the downtime, since you can run it in the hot system , before starting. This run is just to sync from the last call to the time you stopped qmail with the commands above. You are running this in your new server and server.xxx.com is you old server.
/usr/local/bin/rsync -avz --delete -e ssh root@server.xxx.com:/home/vpopmail/domains/* /home/vpopmail/domains

  • Luckily after some time rsync will finish running. If not, leave it working while go to change the other bits. In order to make the new machine recognise all the users and domains from the old server, you need to do the following:
import(merge) from the old server /var/qmail/assign
import(merge) from the old server /var/qmail/recipients
import(merge) from the old server /var/qmail/control/rcpthosts
import(merge) from the old server /var/qmail/control/virtualdomains


  • To finish add and delete a fake domain using vpopmail. This will make vpopmail read all the files you merged and reorganise them.
From now on, you just need to test the system to assure you got everythings working. A good idea before changing the DNS system is to configure an email client with the ip address of the new server an try to send and recieve some emails using all possible combinations.

Finally, keep checking the email server for a day. It is almost impossible to make everything work without mistakes.

2 comments:

Unknown said...

If you are interrested, I've made an updated version of qmailrocks for Debian. It's available on http://qmailrocks.thibs.com

Anonymous said...

I am trying to migrate qmail/vpopmail form a unix server to a linux server. How can I do this?