Backup cPanel and Restore to Another Server

Making a Backup in cPanel


Restoring From Backup


To restore a full backup created from a cPanel server you must transfer the archive file to the server you want to retore it to and save it in the /home folder. Transferring this file is best done via SCP, if your transferring from server to server and have access to the ssh interface for both servers you can use the command line scp command like this on the server you backed up:

#scp  filename user@ipaddress:/home  

If you do not have ssh access to both servers you should use your FTP credentials to move the file from the server you backed up to the new server or to your desktop for transfer to the new server via WinSCP (See article titled "Uploading Content to Your Server"). Or you can use file manager in cPanel to move the file to the public_html directory of your website (/home/cpanel_username/public_html) and download it using your browser at http://website_name/backup_filename or via wget on the server you are transferring the data to with wget http://website_name/backup_filename. Ensure your present working directory is appropriate for the download. The restorepkg script will search for the archive file in the following locations:

  • /home
  • /home2
  • /home3
  • /root
  • /usr
  • /usr/home
  • /web

Once the archive file is fully transferred and located in /home, login to the server you are restoring the account to via ssh (see article "Getting Conencted to Your Server"), and run this series of commands:

  1. cd /home
  2. /scripts/restorepkg username

**Please note that if you already created the user account you are trying to restore this method will fail with errors and corrupt data you may have already uploaded or created. To bypass this error and destroy all data on the previously created account use the --force switch before the username (/scripts/restorepkg --force username).



Configure Changes for cPanel


After the restore is compelted your website should be viewable. However there are some errors you may see instead. Here are some common items that may need to be reconfigured to bring your site online:

1. If you receive a database related error such as:

Error establishing a database connection


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 is that your website cannot communicate with your database due to user account credentials. You need to assign a database username and reconfigure your website's database settings.

    1. Login to your cPanel and click the "MySQL Databases" icon.
    2. Scroll down untill you see MySQL Users > NewUser.
    3. The username can be any username.
    4. Pick any random password. Copy the password and keep it ready.
    5. Enter the password twice and then press the "Create User" button.

The user has now been added, but it has not been assigned to a database.

    1. In the same area under MySQL Users you will see a second section called Add User To Database.
    2. Choose the username you just created from the drop down. (Notice that cPanel will automatically prepend your database name with your cPanel username. Copy this username and keep it ready.
    3. Next, choose the name of your database and click the "Submit" button. If you don't know which database name to use, skip this step for now.

Now you need to locate your database configuration file.

    • If you have a general error message like the first example, then contact your we developer to determine the location.
    • If you have a specific error message like the second example, then the error tells us the location. In our example the error says "in /home/username/public_html/includes/db.php on line 19". That is where you need to go.

It is time to reconfigure your website's database settings.

1. Go to the configuration file and choose to Edit.

2. Look in the code for a place where your database name is defined. Here is the example of what we see:

define('DB_NAME', 'db_name');
define('DB_USER', 'db_username');
define('DB_PASSWORD', 'db_user_password');
define('DB_HOST', 'localhost');

3. The database name is very important; it must have your new cPanel name in the first part. Update the part before the underscore, but change nothing after the underscore. 

4. Next, get the database username and password you set aside and replace the ones in the file. 

5. Save the file and you are done! Refresh your webpage to see if it works.



It is not uncommon that some configuration changes may be required to database configuration file. Here is a short list of some common database applications that may need some changes and their associated configuration files:

  • WordPress: wp-config.php
  • Joomla: configuration.php
  • Magento:  app/etc/local.xml

  • 0 Users Found This Useful
Was this answer helpful?

Also Read

cPanel Disk Space Usage NA / ∞

Hello Sometime I'm asked buy x3host Hosting why my cPanel client can't verify the cPanel host...

How to add favicon to WHMCS theme.

1. Create 16x16 PNG favicon file and place it in WHMCS template folder. (e.g....

How to Register your Nameservers and Point Them with IPS

Hi guys,We are going today to explain how to point our ips with your custom nameservers through...

How Zamfoo Root / Alpha / Master / Super Alpha Looks Like! Surprise!

Here's How Zamfoo Root / Alpha / Master / Super Alpha Looks Like! Surprise!If you are a visitor...

How to grant account with Master Reseller Rights Using ZAMFOO into WHM

Hi,We are going today to explain How to grant account with Master Reseller Rights Using ZAMFOO...