How to migrate CPanel Account manually from backend
How to migrate CPanel Account manually from backend
Posted on : 03-11-2018
In this article, we are going to see about the efficient and fastest method to transfer WHM accounts from one server to another and restoring the same in new server.
Assumption :
If we need to migrate all the user accounts of WHM/Cpanel from server 1 to server 2. Say, Server1 Cpanel license gets expires soon. In this case, we are in urgency to migrate the domains from server1 to server2 for seamless hosting.
Note : Before proceeding this, we have to inform the domain owners regarding this migration. So that they might also aware of it and during this transfer there may be chance of failing updates/new files will may not be added in the database.
Once everything confirmed with proper acknowledgement follow the below steps,
Illustration 1: For migrating single account from server1 to server2
Step 1 : Need to backup the Cpanel account of server 1 (current using server)in the migration format as shown below,
Assumption : In server1, Cpanel account are running in the path : /home
So, login as root user and perform the following commands,
cd /home
/script/pkgacct <accountname1>
Now, you can find the file in tar format as :cpmove-accountname1.tar.gz
Step 2 : Using rsync or scp command you can transfer the file from server1 (/home) to server2 (/home)
cd /home
scp -rf cpmove-accountname1.tar.gz root@<server2_ip>:/home
Step 3 : Restoring the Cpanel account in Server 2
Follow the commands as mentioned below,
cd /home
Find the file .tar format in /home directory (which we have sent from server1) and do the following execution,
/scripts/restorepkg cpmove-accountname1.tar.gz
Note : for restoring there are multiple options available, please do follow this link as per your requirement.(https://documentation.cpanel.net/display/68Docs/The+restorepkg+Script)
That’s it! You have successfully restored for the domain (accountname1)
Illustration 2: For migrating multiple accounts from server1 to server2
Step 1 : Need to backup the Cpanel accounts of server 1 (current using server)in the migration format as shown below,
Assumption : In server1, Cpanel accounts are running in the path : /home
So, login as root user and perform the following commands,
cat /etc/userdomains > /root/users.txt
for i in `cat /root/users.txt $i `;do /script/pkgacct $i ; done;
also, execute the following command to save the user account list in the old server.
cat /etc/trueuserdomains | cut -d: -d' ' -f2- > /root/acctlist
By executing the above command, list of all the usernames are stored in the path /root/acctlist. Copy this file to new server.
Step 2 : Using rsync or scp command you can transfer the files (cpmigration tar files and acctlist file) from server1 (/home) to server2 (/home)
cd /home
scp -rf cpmove-accountname1.tar.gz root@<server2_ip>:/home
Step 3 : Restoring the Cpanel accounts in Server 2
Follow the commands as mentioned below,
cd /home
Find the files .tar format & acctlist file in /home directory (which we have sent from server1) and do the following execution,
run this below command in screen so that seamless restoration will be ensured.
cd
screen
for i in `cat /root/acctlist` ;do /scripts/restorepkg $i ;done
Note : for restoring there are multiple options available, please do follow this link as per your requirement.(https://documentation.cpanel.net/display/68Docs/The+restorepkg+Script)
That’s it! You have successfully restored for the domain (accountname1)
========================
Note : The above given instruction is to restore accounts freshly in new server (server2).
If we want to restore a package for an existing account with the same username as another existing account use following options in above given scripts.
for single account :
/scripts/restorepkg --force cpmove-accountname1 /scripts/restorepkg --skipaccount cpmove-accountname1
for multiple accounts :
/scripts/restorepkg --force $i /scripts/restorepkg --skipaccount $i
================