Guide updated on 29th of December 2011

Update from an old qmailrocks.org installation


Following instructions supposes you want to migrate your data from a server installed with original qmailrocks.org guide into a server freshly installed following this updated guide

This how to 'll refer to OLD_SERVER (server installed with old qmailrocks guide) and NEW_SERVER (server installed with updated qmailrocks guide)

1° Install synchronisation tool on BOTH servers

aptitude install rsync ssh

2° On OLD_SERVER server : stop apache service (needed for administration tools), backup and copy the vpopmail database

/etc/init.d/apache2 stop
mkdir /backups/
/usr/bin/mysqldump -c -C -e -Q --add-drop-table -uroot -pMySQL_root_password vpopmail | gzip>/backups/vpopmail.sql.gz
scp /backups/vpopmail.sql.gz root@NEW_SERVER:
qmailctl stop

If your installation from original qmailrocks.org was done without MySQL support, you should first convert your installation on OLD_SERVER into a MySQL installation. You can do this with the script vconvert-cdb-sql-big.pl

aptitude install mysql-common mysql-server mysql-client (remember MySQL_root_password)

mysql -pMySQL_root_password

CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY 'VPOPMAIL_PASSWORD';
FLUSH PRIVILEGES;
quit;

chmod +x /downloads/scripts/vconvert-cdb-sql-big (then edit the file and execute it for each of your domains)

2° On OLD_SERVER server : copy config files to NEW_SERVER

cd /var/qmail/control
scp morercpthosts rcpthosts virtualdomains root@NEW_SERVER:/var/qmail/control
cd /var/qmail/users
scp assign root@NEW_SERVER:/var/qmail/users/

3° On OLD_SERVER server : determine UID/GID for some users

grep vpopmail /etc/passwd | cut -d: -f3
We 'll refer this value as VPOPMAILUID later

grep vpopmail /etc/passwd | cut -d: -f4
We 'll refer this value as VCHKPWGID later

This second value should be the same as the result of the command
grep vchkpw /etc/group | cut -d: -f3

4° On NEW_SERVER server : stop mail services and synchronise e-mails

qmailctl stop
gunzip /root/vpopmail.sql.gz
mysql -Dvpopmail -pMySQL_root_password < /root/vpopmail.sql
sed "s/VPOPMAILUID:VCHKPWGID/89:89/g" /var/qmail/users/assign > /var/qmail/users/assign.new
mv /var/qmail/users/assign /var/qmail/users/assign.old
mv /var/qmail/users/assign.new /var/qmail/users/assign
/var/qmail/bin/qmail-newu
/var/qmail/bin/qmail-newmrh
rsync -avz --delete root@OLD_SERVER:/home/vpopmail/domains/ /home/vpopmail/domains/
find /home/vpopmail -uid VPOPMAILUID -exec chown vpopmail {} \;
find /home/vpopmail -gid VCHKPWGID -exec chgrp vchkpw {} \;

5° Edit the file /downloads/scripts/migrate-vpopmail-many-domains (View the script migrate-vpopmail-many-domains) on NEW_SERVER:

DATABASE_ROOT_PASSWORD=MySQL_root_password

Adapt database structure

chmod +x /downloads/scripts/migrate-vpopmail-many-domains
/downloads/scripts/migrate-vpopmail-many-domains

6° Adapt your MX setting in your DNS configuration. Then, execute following command on NEW_SERVER

qmailctl start

That's all folks !

If you need more info or if you need to migrate only some domains, take a look to http://qmail.jms1.net/scripts/migrate-domain.shtml

List of optional features


Users comments
Thibs - 16/01/2012 22:19

Jevgenijus : Thanks for the info ! To be honnest I never had the opportunity to test it because my installation was with MySQL

 

 

Jevgenijus - 15/01/2012 14:01

This migration doesn't work correctly from original qmailrocks.org guide without mysql db.

The problem is in vconvert-cdb-sql-big.pl script which create vpopmail table without one field pw_clear_passwd, but migrate-vpopmail-many-domains script use this field in import.

My temp solution was to delete this field and rerun migrate-vpopmail-many-domains script. After that I've added this pw_clear_passwd field.

 


Color Coded Qmail Installation Key
  Regular Black Text     Qmail installation notes and summaries by the author.
  Bold Black Text     Commands to be run by you, the installer.
  Bold/Regular Red Text    Vital and/or critical information.
  Regular Blue text     Denotes helpful tips and hints or hyperlinks.
  Regular Orange Text     Command line output.
  Bold/Regular green text     Denotes the contents of a file or script.