cPanel Backup and Restore

Sometimes it becomes necessary to move a website from one server to another. If you are using cPanel, first you need to backup your site and then restore it to the destination server. Therefore, the entire process can be broken down in two steps. Let’s discuss each of them separately:


Restore cPanel WHM user or single domain Backup through command line.

Backup in cPanel:

  1. Select Backup starting from the first page
  2. Choose “Full Backup” from the second page
  3. Select a destination folder where you want to backup your files. You can save the files to three different destinations:
  4. You can store the files to the root directory of your server
  5. You can save the files to a remote machine using FTP or SCP
  6. You can download the files to your local computer
  7. Enter an email address in the mentioned field. Once the backup process is completed, you will be notified through an email.
  8. Click “Generate Backup” button.
  9. If you wish to download the backup files to your computer, you can do so by clicking the filename under “Backups Available for Download”.

The files backed-up contain the date of backup in MM-DD-YYYY format. The files will be converted into compressed folder with .tar.gz format. You can access these files through SSH or file manager.

Restoring From Backup

Restoring the files from backup is quite similar to uploading the files to the server. To do this, you need to transfer the archive file to the destination server in the /home folder. Transferring through SCP is easiest and quickest. Alternatively, you can use the following command to transfer the files:

#scp filename user@ipaddress:/home

If you do not have the access to both SSC servers, you will have to transfer the files manually through file manager. For this, the files will be stored in the public_html directory of your website.

Once the archive file is fully transferred to the /home folder, you can run following commands to locate the files:

cd /home

/scripts/restorepkg username

Configuring the changes:

Once the restore is done, you will be access to browse your website. However, there are instances when you face some errors. Here are some of the common errors you may face and that need to be configured:

if you receive a error like “Error establishing a database connection” or “Warning: mysql_connect(): Access denied for user: ‘db_username@localhost’ (Using password: YES) in /home/username/public_html/includes/db.php on line 19” “Unable to connect to database server!”, this means your website fails communicating with the database due to wrong account credentials. To resolve this issue, you will need to reconfigure your website database and assign a database username. To do this, follow these steps:

  1. Login to your cPanel account and click “MySQL Database”
  2. Scroll down to MySQL Users -> NewUser
  3. Enter any username and password twice, and click “Create User” button

This will create a new user, but you still need to assign it to the database. In the same area, you will see a section called “Add User To Database”. Choose the username you have created from the dropdown. Then select the name of your database and click the “Submit” button. If you are not sure about the database name, skip the step for now.

Now you need to configure the database. To do this, follow these steps:

  1. Go to the configuration file and select “Edit”
  2. Search the code for the database name. You will see something like this:

define(‘DB_NAME’, ‘db_name’);

define(‘DB_USER’, ‘db_username’);

define(‘DB_PASSWORD’, ‘db_user_password’);

define(‘DB_HOST’, ‘localhost’);

  1. the database name will contain your new cPanel name in first part. Change the first part before the underscore and leave everything else unchanged.
  2. Set the database username and password.
  3. Save the file.

Once this is done, the cPanel backup and restore is complete. You have successfully transferred your website from one server to another.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.