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
2° On OLD_SERVER server : stop apache service (needed for administration tools), backup and copy the vpopmail database
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
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)
3° On OLD_SERVER server : copy config files to NEW_SERVER
scp morercpthosts rcpthosts virtualdomains root@NEW_SERVER:/var/qmail/control
cd /var/qmail/users
scp assign root@NEW_SERVER:/var/qmail/users/
4° On OLD_SERVER server : determine UID/GID for some users
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
5° On NEW_SERVER server : stop mail services and synchronise e-mails
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 {} \;
6° Edit the file /downloads/scripts/migrate-vpopmail-many-domains (View the script migrate-vpopmail-many-domains) on NEW_SERVER:
Adapt database structure
/downloads/scripts/migrate-vpopmail-many-domains
7° Adapt your MX setting in your DNS configuration. Then, execute following command on NEW_SERVER
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
Users comments
Thanks great for your detailed guide. It works.
Due to the other developed programs on the concept of one domain one table, I would like to retain this topology instead of many domains on one table.
I could not locate on the courier section to make this possible.
Please give the hints or any advice.
Thank you in advance.
@BSTD : It was mainly due to the fact my own previous installation was with MySQL ;-)
Ooops, it seems an important part of the insert statement below went missing, which leads to a syntax error. The correct script is:
for D in `find /home/vpopmail/domains/ -maxdepth 1 -type d`;
do
awk -F':' '{split($6, dom,"/"); printf "INSERT INTO vpopmail VALUES ('\'%s\'', '\'%s\'', '\'%s\'', 0, 0, '\'%s\'', '\'%s\'', '\'%s\'', '\'%s\'');\n", $1, dom[5], $2, $5, $6, $7, $8 >> "ALLUSERS.sql";}' < $D/vpasswd;
done;
Sorry for any inconvenience...
Greets
First of all, thank you, Thibs, for this wonderful guide.
Now, I have stumbled across a migration between an old vpopmail version with vpasswd and a new vpopmail with mysql. Personally, I find it useless and inefficient to convert from vpasswd to mysql on the OLD server and then dump the database and transfer it to the new one. So I wrote a cool script to make things a lot simpler. Basically, it creates a list of all the INSERT statements needed to add all users from the OLD server to the new. It also preserves the clear password field, if available. Here it is:
for D in `find /home/vpopmail/domains/ -maxdepth 1 -type d`;
do
awk -F':' '{split($6, dom,"/"); printf "INSERT INTO vpopmail ('\'%s\'', '\'%s\'', '\'%s\'', 0, 0, '\'%s\'', '\'%s\'', '\'%s\'', '\'%s\'');\n", $1, dom[5], $2, $5, $6, $7, $8 >> "ALLUSERS.sql";}' < $D/vpasswd;
done;
So, after executing this code, you have an ALLUSERS.sql file in your current directory. Transfer this file to the NEW server and import it in the vpopmail database. Of course, the other steps described on this page are still required.
Greets
Jevgenijus : Thanks for the info ! To be honnest I never had the opportunity to test it because my installation was with MySQL
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.
Dear All,
Thanks great. It is my mistake to overall the option of vpopmail-many-domains