How to migrate a complete cPanel Account via SSH

Follow

Introduction

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.

 

Process

Commands will be italicised.

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 shared hosting, or cPanel account, and navigate to 'Backup' under files:

 

 

Once in the Backup section, you need to click 'Download a full Website Backup' - despite the wording, this is a full account backup and will contain a backup with everything, not just web files.

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

 

3. 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 commnand is optional, but useful to see what the file is called so that you can type it exactly, remember to utilise 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

bye

 

4. Restore the account backup on the new server

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

 

Afterword

The migration tool is very verbose, and will give you heaps of information, if any errors become apparent, the tool will ensure you are aware of this.

Bear in mind, the migration tool will also take initiative in areas such as DNS; it will automatically change and update records that will now be invalid on the new server, such as SPF records. 

 

 

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk