Sunday, July 5, 2009

Migrate Qmail, Vpopmail & SquirrelMail to New Server

Needed to migrate a Qmail, Vpopmail and SquirrelMail from an old machine to a brand new server with Raid 5 capabilities. Everything with the old setup was working as a charm so i wanted to keep my smartness on the hold to not to screw up anything.

Below mentioned is the procedure to effortlessly do the migration.

Setup Raid 5.

Install CentOS 5.2(RAID & LVM).

Install all the needed requirements for the mail server.

Install all the components of the mail server(Qmail, Vpopmail, SquirrelMail, etc).

Login to the old server.

#cd /home/vpopmail/domains

#vi list_vpopmail_users.sh

#!/bin/bash

for domain in *;
do for user in `ls $domain`;
do echo -n "~vpopmail/bin/vadduser" $user@$domain;
~vpopmail/bin/vuserinfo $user@$domain | grep -v "name:\|^passwd:" | sed -e 's/clear passwd://'; done; done | grep -v "no such"| grep @ |sort

#chmod 755 list_vpopmail_users.sh

#./list_vpopmail_users.sh > vpopmail_users

Open vpopmail_users and edit unwanted entries.

Move the vpopmail_users file to the new server.

Login to your new server.

#/home/vpopmail/bin/vadddomain your_domain_name your_postmaster_password

Execute the vpopmail_users file in the new server.

#./vpopmail_users

Now login to you old server.

#cd /root

#ssh-keygen -t dsa -b 1024 -f root_dsa -C 'Root dsa key'

#mv root_dsa /root/.ssh/

#scp root_dsa.pub root@new_server_ip:~

Login to your new server.

#cat root_dsa.pub >> /root/.ssh/authorized_keys

#chmod 600 /root/.ssh/authorized_keys

#rm -rf root_dsa.pub

Login to your old server and issue the following command.

#rsync -avuzr --stats --delete -e "ssh -i /root/.ssh/root_dsa" /home/vpopmail/domains/your_domain_name root@new_server_ip:/home/vpopmail/domains/

Copy SquirrelMail from old to new server.

Login to your new server.

#scp -r root@old_server_ip:/var/www/html/webmail /var/www/html/

I had my SquirrelMail data and attachments in the /var/wmdata and /var/wmattachments. So copy your data and attachments directory from old server to the new one using the scp command.

Next we need to change permissions of the data and attachments directory to enable apache to have write access. Look up apache config to find the username and group under which it runs and change the permissions accordingly.

#chown -R apache:apache /var/your_data_directory

#chown -R apache:apache /var/your_attachment_directory

Next change the ip address used by SquirrelMail by running conf.pl.

#cd /var/www/html/webmail/config

#./conf.pl

And that's it folks!!!.

The solution is nothing new and i have posted what just worked for me. I owe google...

No comments: