Qmail replication

From Noah.org
Jump to navigationJump to search

qmail may have some advantages, but ease of use is not one of them. I went nuts for a couple of hours trying to rebuild our mail server. I was going from a 32-bit kernel to a 64-bit kernel so I couldn't just copy the binaries. I had to rebuild qmail and then move all my mail configuration over.

See also Qmail_64-bit.

How to copy a qmail installation from one server to another

I use rsync for all my file copy steps between servers because this will preserve permissions and translate userid and groupid. Although, as you will see, you will need to manually translate the userid and groupid in one file.

Install a Qmail Rocks version of qmail.

Copy /home/vpopmail from the old server to the new server. This copies all the virtual domain information and user mail files.

Copy /var/qmail/control/ from the old server to the new server.

Copy /var/qmail/alias/ from the old server to the new server.

Copy /var/qmail/users/ from the old server to the new server.

Delete /var/qmail/users/cdb. Edit /var/qmail/users/assign and change all the userid and groupid numbers to the those that match your new system. They may already be the same, but probably not. For example, my old /var/qmail/users/assign file had lines that looked like this:

 +example.com-:example.com:1009:1004:/home/vpopmail/domains/example.com:-::
 +example.net-:example.net:1009:1004:/home/vpopmail/domains/example.net:-::

Now I find out the userid and groupid of vpopmail on my new system:

 # id -g vpopmail
 515
 # id -u vpopmail
 520

So I edit the new /var/qmail/users/assign file to look like this:

 +example.com-:example.com:515:520:/home/vpopmail/domains/example.com:-::
 +example.net-:example.net:515:520:/home/vpopmail/domains/example.net:-::

Regenerate the /var/qmail/users/cdb file from the assign file by running qmail-newu:

 /var/qmail/bin/qmail-newu

Not done yet! Copy your vqadmin .htaccess file from the old server to the new server. For example, on my server it's under:

 /var/www/usr/local/apache2/cgi-bin/vqadmin/.htaccess

Then copy the password file specified in the .htaccess file. Grep for the AuthUserFile line in .htaccess to figure out where this is. On my server is right next to the .htaccess file:

 /var/www/usr/local/apache2/cgi-bin/vqadmin/vqadmin.passwd

Copy /etc/tcp.smtp from the old server to the new server (I'm not certain this is necessary).

On the new server reload tcp.smtp (I'm not certain this is necessary):

 qmailctl cdb