Server to Server Migration

Server to Server migration >> All accounts

====================
Before migration, please have a note on the following
————-

1) Check whether any of the domains are using remote MX entries
cat /etc/remotedomains
2) Check for dedicated IPs used by the accounts. Keep the list of account using ded
cat /etc/domainips
3) Check the ssl certificates installed for any domains
grep SSL  /usr/local/apache/conf/httpd.conf
4) Check whether there is any difference between apache,php,mysql version. Also check both apache and php modules.

Then proceed with the migration
——————————–
1) Keep the list of accounts to migrate on the file /root/myacts.txt
# cat /etc/trueuserowners | awk -F : ‘{print $1}’ > /root/myacts.txt

2) Create  cpmove archive for the  accounts
# for i in `cat /root/myacts.txt`; do /scripts/pkgacct  $i ; done

# for i in `cat /root/myacts.txt`; do /scripts/pkgacct –skiphomedir  $i ; done ( When the size of the home directory is too large, exclude the home directory from the backup. We can sync the home directory later )

3) Copy the cpmove archive for the accounts from the source server to the destination server
# for i in `cat /root/myacts.txt`; do scp /home/cpmove-$i.tar.gz root@IP:/home/ ; done

4) Copy the file contains the list of accounts to the destination server
# scp /root/myacts.txt root@IP:/root/myacts.txt

5) Keep the list of accounts and domains residing on dedicated IP
# cat /etc/domainips  | awk ‘{print $2}’ >> /root/dedicateddomains.txt
# for i in `cat /root/dedicateddomains.txt`; do grep $i /etc/trueuserdomains; done | awk  ‘{print $2}’ >> /root/dedicated.txt

6) Copy the file contains the list of account resinding on dediacted IP to the destination server
# scp /root/dedicated.txt root@IP:/root/dedicated.txt

7) Upon checking the destination server, you may find that only one IP which is the main shared IP is only presnt in the dedicated server. Add  the secondary IPs to the new server
This can be done via WHM in cpanel servers. Please follow the steps

a) Home >> IP Functions >> Add a New IP Address
b) Enter the IP address in the New IP or IP range to add text box.
c) Enter the subnet mask in the Select a subnet mark text box. If you add a single IP address, the subnet mask will be 255.255.255.0.

8) Separate the account such that the account with shared IP and the account with dedicated IP
# sdiff /root/myacts.txt  /root/dedicated.txt | grep “<”  | awk ‘{print $1}’ >> /root/shared.txt

9) Restore the account to shared IP on the new server
# for i in `cat /root/shared.txt`; do /scripts/restorepkg  cpmove-$i.tar.gz ; done

10) Restore the account to the dedicated IP on the new server
/scripts/restorepkg –ip <dedicated IP> cpmove-username.tar.gz

11) Proceed with the rsync of the home directory of the transferred account
# for i in `cat /root/myacts.txt`;do  rsync -avz –progress /home/$i/ root@IP:/home/$i/;done

10) Doing sync the password may be prompting continuously. Then generate the key on the source server and copy the key to the destination server for syncing

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa_migration
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa_migration.
Your public key has been saved in /root/.ssh/id_rsa_migration.pub.
The key fingerprint is:
a9:65:52:a1:c1:fd:b0:69:2b:76:cf:74:63:2f:ba:f6 root@server-name.com
The key’s randomart image is:
+–[ RSA 2048]—-+
|     ….        |
|      .oo.       |
|      . .=       |
|       .+..      |
|      ..S.       |
|      o=o . +    |
|     ..o + o o   |
|          + . .  |
|         .o+E.   |
+—————–+

12) Then copy the public key to the destination server
# ssh-copy-id -i /root/.ssh/id_rsa_migration.pub root@IP

13) Copy the contents on  id_rsa_migration.pub to the file authorized_keys
# cat /root/.ssh/id_rsa_migration.pub  >>  /root/.ssh/authorized_keys

14) The proceed with the rync with the help of the key, there is no need enter the root password of the destination server from now.
# for i in `cat /root/myacts.txt`;do  rsync -avz –progress  -e  “ssh -i /root/.ssh/id_rsa_migration” /home/$i/ root@IP:/home/$i/; done

15) Compare the size of the home directory of the accounts after the migration. execute the following command in both servers.
# for i in `cat /root/myacts.txt`; do  du -sch /home/$i ; done

16) Install SSL certificate for the domains on the new server

17) Compare the disk space usage of the mysql directories of the accounts transferred.
# for i in `cat /root/myacts.txt | sort`; do for j in `ls /var/lib/mysql/ | grep $i`; do du -sch /var/lib/mysql/$j; done done

18) Check whether the file /etc/localdomains, /etc/remotedomains, /etc/domainips are same in both server, it there is any difference please made it same

19) Keep the list of domaian that has been migrated
# cat /etc/trueuserdomains | awk -F : ‘{print $1}’ > /root/mydomains.txt
 
20) Check whether the the zone files got updated with the correct IP address.
for i in `cat /root/mydomains.txt` ; do grep A /var/named/$i.db; done

21) Check whether the the zone files got updated with the correct nameservers.
# for i in `cat /root/mydomains.txt` ; do grep NS /var/named/$i.db; done

22) Check for ssl certificates and its entries in apache configuration file and compare with the old server
# grep SSL /usr/local/apache/conf/httpd.conf

23) Check whether there is any files with ownership mismatch
# for i in `cat /root/myacts.txt`; do find /home/$i/public_html ! -user  $i; done
# for i in `cat /root/myacts.txt`; do find /home/$i/public_html ! -group  $i; done

24) update the IP in which the domain residing on the file ‘/etc/hosts‘ in your local machine and check whether the transferred domains are loading fine from the new server

============================

1st

Source server:
cat /etc/trueuserdomains | wc -l
take the owners to a file
cat /etc/trueuserdomains | awk ‘{print $2}’ > /home/list.txt
then take the backup of all the account eg:server contains 10 cpanel accounts
for i in ‘cat /home/list.txt’; do /scripts/pkgacct $i newfolder; done
Now the new folder contains all the tar files

Copy this to destserver using scp

from the destination.
cat /home/newfolderfile | awk ‘{print $1}’ > /home/new.txt
for i in ‘cat /home/new.txt’; do /scripts/phgacct $i ; done

or refer the below url.
http://www.sohailriaz.com/how-to-transfer-cpanel-accounts/

=====================

 

This is better than first,

For faster migrations use rsync and skip home directory
From source:
cat /etc/trueuserdomains | awk ‘{print $2}’ > /root/list.txt
for i in `cat /root/list.txt`; do /scripts/pkgacct –skiphomedir $i>>/root/backup.log;done;

cd /home
mkdir Cpmove
mv cpmove-* Cpmove
compress the file Cpmove and move to /home of destination server.

scp /root/list.txt root@ip:/home

scp Cpmove.tar.gz root@ip:/home/

In dest server:

for i in `cat /home/list.txt`; do /scripts/restoreacct cpmove-$i.tar.gz;done;

From source server :

for i in ‘cat /root/list.txt’; do rsync -avz –progress /home/$i/ root@ip:/home/$i/; done;

======FYI }

After that using rsync copy the home directory to destination
rsync -avz /home root@ip:/home

If the ssh using port
then use

rsync -avz -e ‘ssh -p 233’ /home root@ip:/home

Here is what the “-arvz” option does:
a = archive – means it preserves permissions (owners, groups), times, symbolic links, and devices.
r = recursive – means it copies directories and sub directories
v = verbose – means that it prints on the screen what is being copied
z = compress file data during the transfer

completed the migration.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s