July 6, 2021 . 5 MIN READ
https://www.serverpronto.com/kb/page.php?id=Backup+cPanel+and+Restore+to+Another+Server
Making a Backup in cPanel
To create a full backup:
The date the backup was created appears in the filename (which begins with backup-MM-DD-YYYY). The file will be stored as a “tar ball,” or compressed data file, with the filename extension .tar.gz in the /home/cpanel_username directory. You can access this directory through file manager or via ssh if you have ssh access to the server.
Note: You cannot use a full backup to restore your site via the cPanel interface. The file must be downloaded and decompressed prior to restoration. Once the file has been decompressed, you will be able to upload and restore individual pieces of your website contained within the full backup.
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:
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:
**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:
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 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.
The user has now been added, but it has not been assigned to a database.
Now you need to locate your database configuration file.
It is time to reconfigure your website’s database settings.
define(‘DB_NAME’, ‘db_name’);
define(‘DB_USER’, ‘db_username’);
define(‘DB_PASSWORD’, ‘db_user_password’);
define(‘DB_HOST’, ‘localhost’);
**Note
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:
Magento: app/etc/local.xml