Announcement

Collapse
No announcement yet.

How To Transfer CPanel Accounts through shell

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How To Transfer CPanel Accounts through shell

    How To Transfer CPanel Accounts


    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
    Code:
    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.
Working...
X