In this how to i will describe how to transfer CPanel accounts from one server to another. To transfer account you should have root access on both servers. Because to transfer account you need every thing to backup for transfer including Cpanel User / Pass (Same), Website, Database, Emails, Users, Stats etc. The thing i like about CPanel is it will transfer accounts 100%, you will not miss any single think related to your accounts. This method implies on VPS’s and Dedicated Server where you can access WHM (Web Host Manager) or root shell.
Lets consider we have two servers A and B. Server A is the old server with two accounts and Server B is new server to which we will transfer accounts.
Server A = 192.168.0.1
Server B = 172.20.0.1
1 Transfer using WHM
Login to Server B WHM using following url
http://172.20.0.1:2086
where 2086 is the port on which WHM is running.
In the middle page select Transfer and then on Transfer page select Copy multiple accounts/packages from another server.
It will open new page to put info of the Server through which you are going to transfer i.e Server A.
Remote server type is (WHM version will be auto detected on multi account copies): leave as it is
Remote server address (ip address or FQDN): put server hostname or IP
Remote SSH port: 22 is the default, if you have changed ssh port on old server use that one here.
Do not compress transfers (cPanel 10.8.3+ required on both ends): leave at it is
Turn off SSL (cPanel 11.23.6+ required on both ends): leave at it is
Allow override*: leave at it is
Login as : Choose USER if you have sudo or direct root login are not allowed. Else select ROOT (recommended)
Select authentication method: Choose Password here, if you are using Public Key then you have to upload Key using Security -> Manage SSH Keys to use here.
Root Password: put root password here
After putting all information above click on Fetch Account List. In few second you will see list of accounts from Server A to transfer. Select the account using check boxes to copy, if need to copy all select Select All to check all accounts. When done with select click on Copy. (Beware once you click on Copy dont close browser or click on Back button).
You will see account transfer log on your browser and when finished it will show nice summary about transfer.
2 Transfer using Shell (Command Line)
SSH your Server A using putty from windows and command line from linux.
ssh 192.168.0.1
Now first of all we will create full backup to transfer and all the backups created are placed under /home directory.
2.1 Create One Account Backup
If you wish to backup single account, then execute following command
/scripts/pkgacct cpaneluser
you will find corresponding backup in /home directory named cpmove-cpaneluser*.tar.gz
2.2 Create all Accounts Backup
To create all accounts backup on your server, execute following command
cat /var/cpanel/users | while read a; do
/scripts/pkgacct $a
done
again you will find all accounts backup under /home named cpmove-cpaneluser*.tar.gz
2.3 SCP Backups to New Server
After creating backup you have to transfer all accounts backup to your new server i.e Server B using SCP.
scp cpmove-* root@172.120.0.1:/home
Besure all backups should move to /home directory of new server.
If you have done all accounts backup then you should have to move /var/cpanel/users file for restore on new server i.e Server B in /home directory with name user.txt
scp /var/cpanel/users root@172.120.0.1:/home/user.txt
2.4 Restore Backup
To restore single account backup execute following command.
/scripts/restorepkg cpaneluser
where cpaneluser is of old server and can be found on backup filename after cpmove. i.e
cpmove-cpaneluser*.tar.gz
To restore all accounts
cat /home/user.txt | while read a; do
/scripts/restorepkg $a
done
Now you can List Account in WHM to see all accounts are transferred successfully to your new server and you can login to cpanel accounts of user using same Cpanel user / pass as old server.
If you have any question please ask in comments.
Hi Sohail, thanks for this tutorial. I tried to transfer an account using SSH
However I am getting stuck at no.3
scp cpmove-[username].tar.gz root@[NEWSERVERIP]:/home/
I get the following error:
root@sun [~]# scp cpmove-*****.tar.gz root@**.**.**.***:/home/
ssh: connect to host **.**.**.*** port 22: Connection timed out
lost connection
I know for a fact that on the new server the SSH allows me to login without any problems. The firewall also is off.
I would really appreciate your input
thanks
The above error is definitely you are not having ssh facility to do from this server to target server.
There is possibility that your current server from which you are executing scp command has problem to do ssh to your new server.
Check following things,
1) On your current server check firewall
2) On your target or new server check the port for ssh is 22.
3) run following command and check you can connect to your target or new server
ssh newserver
mtr newserver
Regards,
FYI
In WHM there are two ways to transfer the sites
* Copy an account from another server
* Copy an account from another server with account password
I was trying to use the second option because i figured i have the password.
Problem is with larger accounts the transfer gets cut off. It tries to transfer the account over using one huge tarball. The transfer goes through and it looks completed but inspecting the site there are may missing files from www/
Then on a whim i tried the first option. Basically the same thing – account name and password BUT the big difference is that the first option splits up the tarball into many pieces and then puts it all together. Much better for moving larger sites and so far since using the first option things are moving along a lot better. Seems a bit slower but at least the transfer is complete.
Hope that helps future requests.
Thanks,
Alex.
@alex: Thanks for sharing the knowledge.
There are four options for transfer and the thing you tell is that either you are transferring account from any other shared hosting or you have less privileges given by your host.
If you see my post, i describe about all accounts. So i used multiple account transfer, which i dont know you have used or not.
And for shell lovers i show them how to use from ssh too. Well transfer using shell is same for everything even you are transferring one account or more.
——–
Regards,
Hello Sohail,
this is nice blog since i’ve read this link, but on this post im still wondering, i try to make bash script to run your command to backup all account, but it’s not well, here’s the error :
cat: /var/cpanel/users: Is a directory
maybe something wrong with my server or something, cause im too tired, need to moved thousand domain without any error 🙁
i prefered manually moved from ssh more than WHM, could you help me please?
thanks in advance
Regards,
Dee
Hello Sohail,
i found solution here, better you edit your post, and change this entry ” cat /var/cpanel/users /scripts/pkgacct $a
done” into “ls /var/cpanel/users /scripts/pkgacct $a
done” now im working on moving account from ssh 🙂
Thanks for great post.
Regards,
Dee
i must say that this is very hepfull.
thanks to Sohail & Dee.
Thank you, you help me to transfer a cPanel VPS to Webmin (Virtualmin)
hi
when i use Transfer using WHM
i got problem i cant write it here becouse its to long
i write the importent lines
>>>> pkgacct started. pkgacct — attempting to use daily backup to create a account package pkgacct — could not use daily backup because it is missin
>>>>> ERROR: Failed to dump one or more databases
how can i solve this problem ?
Hi,
I want to backup all the accounts except for one account, is there any command i can put into the script to exclude that account ???
@shahzaibcb: Do the following to exclude that one account. In the above my script for backup, change the file line like this
cat /var/cpanel/users | while read a; do
to
cat /var/cpanel/users | grep -v yourexcludeaccountname | while read a; do
———
Regards,
@sohail thanks for reply, the command cat didn’t worked for me regarding creating of the packages of the accounts instead i use
“ls /var/cpanel/users | while read a; do”
the issue i’m having is that the pckacct backup process times out after about 2 hours on a 38G large account. How do I get around this??
Thanks Sohail, Very useful information!! Due to firewall, I couldn’t use WHMCS transfer, it kept timing out but the method you described here worked!