Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Outline Of cPanel Migration and Tips For Easy Migration  (Read 9314 times)

0 Members and 1 Guest are viewing this topic.

Tinu

  • Guest
Outline Of cPanel Migration and Tips For Easy Migration
« on: March 01, 2015, 01:51:12 pm »
What is cPanel Migrations ?

cPanel migration is the process of copying per-formatted account packages from one server to another.



Why Migrate ?

* Upgrade Hardware
* Operating system upgrade
* System/Hardware crash


What is migrated ?

* Web Content and Files
* MySQL or Postgre SQL Databases.
* Email Accounts
* FTP Accounts
* Web Statistics
* Domain Configurations
* Reseller Configurations
* Custom DNS zone files
* Hosting Packages

Migration Task Over View

* Evaluation
* Remove Unwanted Files and Backups
* WHM GUI Account Migration
* Manual Migration
* How To Transfer Large Accounts
* How To Restore Accounts With Dedicated IP
* DNS Changes


Why Evaluation ?

* We need to migrate as fast as possible
* We want to conduct a smooth transfer
* Recompile server software’s
* Help to develop a Migration Plan
* Client website need to work as expected

Migration Evaluation Includes:

* HDD space (Large accounts)
* How file system partitions are allocated
* Incompatible user names
* PHP modules and versions
* Apache modules and version
* Database version
* IP usage and availability
* SSH connectivity between servers
* Check TTL's of your nameserver


Remove Unwanted Files


Remove unwanted files and backups:

* Remove Error Logs under each accounts:

# find /home*/*/public_html/* -type f -name 'error_log' -exec rm -rvf {} \;

* Find and Remove unwanted backups under each accounts home directory

# find /home*/*/ -iname 'backup-*.tar.gz'

Check for backups using above command and remove them one by one manually.



Always migrate Small accounts ( < 1GB ) using the following steps:

WHM GUI Account Migration (Step 1 to 7)


Step 1: Log into WHM on our server.

Step 2: In the top-left Find box, type in transfer, then click on

“Copy multiple accounts/packages from another server”

Step 3: Remote Server Info section


* Now you'll be presented with a drop-down list for Remote
Server Type, in this example we're going to assume your
previous host was using WHM/cPanel and select that from the
drop-down.

* For the Remote Server Address field you'll want to type in the
current IP address of your website on the old server, or your
domain name if it's still pointed to that server.

* By default the Remote SSH port should be 22, you can click
on Check SSH Connection directly below this setting to ensure
it's set correctly.

* If you receive an error of Connecting to Remote Server Failed
this typically means that your server's IP address with us isn't
allowed in your old server's firewall.


* Once you establish a SSH connection
successfully you should get a message like:

“Remote Server Ok: SSH-2.0-OpenSSH_5.3”

* Use SSL should be enabled if possible

* Use Incremental Backups speed-up options (It is not recommend leaving the Don't Compress Transfers option disabled.)



Authentication section

In this section for Login, select Root
Then you can choose either option for Authentication Method
and enter in either the Root password or public key.
Finally click on the Fetch Account List button at the bottom of
the page to start the copy process.



Step 4: At the bottom of screen you can select
the cPanel accounts that you'd like to transfer. For
this example we are not copying over any
packages just the accounts.
You can also select to skip certain parts of the
account copy if you'd like by placing a check mark
in the column for each option.

Finally click the Copy button at the bottom of the
screen to begin the copy process.


You'll get a pop-up window telling you not to close the
web-browser while the copy takes place, click OK to
continue and be sure to leave your web-browser open
until the copy completes.

Step 5: After the copy has completed you'll get another
pop-up warning you not to click the back button in your
web-browser, click OK.



Step 6: You'll now be on the Review Copied Accounts
page, you can click on View Log beside any account to
review the log of that account's copy process. Or you can
simply close this new window in your web-browser which
should drop you back to your window with the main WHM
interface.

Back end log files are in : /var/cpanel/logs/


Step 7: Now that you've successfully copied over your
accounts from an old server to your new server, you'll want to
be sure to check it on the new server using the temporary
URL, or by modifying your local hosts file.
http://1.2.3.4/~username

Or Edit your personal system's host

file “/etc/hosts”
# vi /etc/hosts
------
1.2.3.4 example.com
-----

Call domain “example.com” from your browser.
Once you've verified that everything seems to be properly
copied over you'll want to update your domain's name servers
to point to us so that when people try to access your domain
name the new IP address of your new server is where they're
getting directed to.



Manual Migration (Step 1 to 3)



Why use Manual Migration ?

* Large amount of Web or Email contents
* Slow network connectivity
* Want more control over migration process
* Lack of space on either server



Requirements & Skills

* Need SSH root access to do manual migrations
* Need to know SSH port,wheel users,keys
* Need to know basic bash commands like cp,rsync,scp,for,do/done,cat etc..
* Need screen package installed and you need to know screen commands like screen



Step 1

On the Old server Run these commands :

# cat /etc/trueuserdomains | cut -d: -f2 > Migration.txt
# screen
# for i in `cat Migration.txt` ; do /scripts/pkgacct $i ; done



Step 2

On New Server Run these commands:

* Setup password less ssh authentication from New to Old server:
# ssh-keygen
# cat ~/.ssh/id_rsa.pub
# cat ~/.ssh/id_rsa.pub | ssh root@OLDSERVERIP 'mkdir .ssh ; cat >>
.ssh/authorized_keys'

* Copy account packages from old server to new server
# screen
# rsync -avp - -progress - -log-file=/var/log/sync.log -e “ssh -p 22” root@OLDSERVERIP:/home/cpmove-*.tar.gz /home/





Step 3

On New server Run these commands
Copy “Migration.txt” from OLD server and then restore accounts using :

# screen
# for i in `cat Migration.txt`; do /scripts/restorepkg $i ;done

How To Transfer Large Accounts


Always migrate large accounts ( > 1GB ) using the following steps:

* Package account using

# /scripts/pkgacct - -skiphomedir $USER

* Copy accounts packages to new server rsync or scp

* Restore Package using :
# /scripts/restorepkg $USER

* Copy Home directory from OLD to NEW server
# rsync -avp - -progress -e “ssh -p 22” root@OLDSERVERIP:/home/$USER/ /home/$USER



How To Restore Accounts With Dedicated IP

Check free IP using script

# /scripts/ipusage and assign a free IP to the new cPanel user
# /scripts/restorepkg - -ip 1.2.3.4 $USER




DNS Changes Before And After Migrations



DNS CHANGES BEFORE MIGRATIONS:

The major problem that you might face in domain migration is the DNS
caching problem. When a remote DNS resolver will make a query to one
authoritative DNS server and if the query is successful it will cache that
response for a predefined time. This time is so called TTL value. Thismeans that for that amount of time the particular server will use its
cached information and no longer query the authoritative server for anyadditional requests.

In order to avoid this problem, bring down the TTL value to 300 secondsand reload rndc, 24 hours prior to migration. This can be done by
changing the TTL value in the zone file of the domain. If the domain has
addon domains, make sure that the TTL values in their zone files are
also brought down. Thus zero down time can be achieved instead of a
high value of 24 - 48 hours.



Run these commands from OLD server 24 hours prior to migration

# cp -apf /var/named/ /var/named-backup

# vi serial.sh
------------
#!/bin/bash
TTL1=14400
TTL2=86400
TTL3=150
TTL4=300
for i in $(ls /var/named/*.db);
do
if [ -f $i ];
then
OLD=`grep Serial $i | awk '{print $1}'`
NEW=$(($OLD + 1))
sed -i "s/$OLD/$NEW/g" $i
sed -i "s/$TTL1/$TTL3/g" $i
sed -i "s/$TTL2/$TTL4/g" $i
echo "fixed $i"
fi
Done
-----------

# sh serial.sh
# /etc/init.d/named configtest
# /etc/init.d/named restart



After Migration, Change The IP Address For The Nameservers
After domain migration, change the nameservers for the domains
to point to new server IP address. Once the domain starts digging
from the new server you can again increase the TTL values of the
sites to the original value after everything is propagating from the
new IP.




Run these commands from NEW server after DNS propagation completes:

# cp -apf /var/named/ /var/named-backup

# vi serial.sh
------------
#!/bin/bash
TTL1=14400
TTL2=86400
TTL3=150
TTL4=300
for i in $(ls /var/named/*.db);
do
if [ -f $i ];
then
OLD=`grep Serial $i | awk '{print $1}'`
NEW=$(($OLD + 1))
sed -i "s/$OLD/$NEW/g" $i
sed -i "s/$TTL3/$TTL1/g" $i
sed -i "s/$TTL4/$TTL2/g" $i
echo "fixed $i"
fi
Done
-----------

# sh serial.sh
# /etc/init.d/named configtest
# /etc/init.d/named restart


* Switch-off the services in the old server after making sure the log update .
* Double check the account list in both servers and make sure the migration is done for all the accounts.

“ Ensure every thing is migrated and all sites are working Fine”

****************Hope next time you can do better Migrations*******************