How To Migrate A Complete cPanel Account Via SSH?

Migrating an account using cPanel's migration tool is extremely useful, and rather bullet-proof. 

The basic principle, is the account will be packaged up in it's entirety; public_html website files, databases, all DNS settings, emails, etc; and places them into a nice little .tar.gz file, marked

backup-[Timestamp]_[Account Name].tar.gz

The aim is to get this file packaged up, sent off to the receiving server, and then unpackaged and restored.

You will need access to the old server, either SSH, or FTP will do. If you don't have SSH root access, you will need to create a 'Full Account Backup' using the cPanel login you have.

Root & SSH Access:

1. Log into source / old server

ssh root@oldip

2. Create account backup file

/scripts/pkgacct account-name

This command will create the archived file, and place it in the /home/ directory of the OLD server.

3. Transfer account backup file to other server

Now we will need to get it over to the receiving / new server, this can be done a number of ways, the most common being SCP, as it is available on any server running SSH, and allows placement of the file anywhere that the destination user has access to, ie. root being everywhere.

scp /home/backup-x.x.xxxx_xx-xx-xx_account-name.tar.gz root@destinationIP:/home/restoreme.tar.gz

Breakdown of the above command: 

scp | Initiating the Secure Copy

/home/backup-x.x.xxxx_xx-xx-xx_account-name.tar.gz #| The source, or local file
root@destinationIP:/home/restoreme.tar.gz #|The user, destination, and location you wish for it to go.

4. Restore account backup

Once this transfer is completed, we are now done with the Old / source server, and can logout.

We will now need to log into the destination server via SSH, and run one single command,

/scripts/restorepkg /home/restoreme.tar.gz

This command will unpackage the account, create all the databases, email and accounts etc.

Ensure you don't close the terminal during this process, it can take up to 30 minutes to complete.

cPanel Account Access:

1. Create account backup

Login to cPanel account, and navigate to 'Backup' under files

Once in the Backup section, you need to click 'Download a full Website Backup'.

Now you will want to enter an email address to receive the notification of completion - and click  'Generate Backup'.

2. Get the account backup transferred.

Once the account backup file has been created, you can now proceed to transfer it over to the new server.

The easiest way to do this will be to SSH into the destination server, and then use FTP to transfer it over.

ssh root@destinationserver
ftp ftp://account-name@old-server-ip

Enter Password

Now you will be logged into the FTP server on the OLD server FROM the NEW server, you can proceed to download the file to the new server by using the following commands

ls

This command is optional but useful to see what the file is called so that you can type it exactly, remember to utilize the tab key to autocomplete the filename to make things easier.

get backup-x.x.xxxx_xx-xx-xx_account-name.tar.gz /home/restoreme.tar.gz

This command will retrieve the account backup file, and place it in the /home/ directory on the new server.

Once the transfer is completed, log out and exit ftp.

4. Restore the account backup on the new server

/scripts/restorepkg /home/restoreme.tar.gz
Was this answer helpful? 0 Users Found This Useful (0 Votes)