Moving vpopmail directories

For years I have somehow thought moving vpopmail domains between vpopmail installs was hard (ie. from one server to another). I even went so far as to custom build vadddomain binaries which forced creation to a particular directory (ie: /home/vpopmail/domains/0/, /home/vpopmail/domains/1/).

If you are not familiar with the “problem” it is that in larger installs vpopmail balances the mail directories among subdirs in ~vpopmail/domains. If all your domains are in a single directory (~vpopmail/domains) you are fine – just vadddomain on the new machine then rsync the data directories. The problem arises when you vadddomain on the new install and it assigns a different directory on the new server than on the old one.

Because qmail stores much of the mapping in cdb databases I somehow began thinking it would be a lot of work to update these. I was wrong. It is actually quite easy. First, tar up the users dir on the source server :

cd /
tar czpf /root/backup.tgz /home/vpopmail/domains/2/whatever.org

On the new server:

~vpopmail/bin/vadddomain whatever.org
cd /
wget http://whatever.org/backup.tgz
tar xzpf backup.tgz

Edit /var/qmail/users/assign – vadddomain likely created the new install using a different subdirectory.

emacs /var/qmail/users/assign
# edit the directory the domain maps to (should be the last line in the file)
/var/qmail/bin/qmail-newu

Confirm all is well with a vdominfo on the new server:

~vpopmail/bin/vdominfo whatever.org

This should show the “old” vpopmail directory that you copied over. As always send a test to make sure all is well. Start with a local test before updating DNS, if the test is delivered correctly, update DNS and test remotely.

Leave a comment

Your email address will not be published.