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 into two steps. Let’s discuss each of them separately:
Backup in cPanel:
- Select Backup starting from the first page
- Choose “Full Backup” from the second page
- Select a destination folder where you want to backup your files. You can save the files to three different destinations:
- You can store the files in the root directory of your server
- You can save the files to a remote machine using FTP or SCP
- You can download the files to your local computer
- Enter an email address in the mentioned field. Once the backup process is completed, you will be notified by an email.
- Click “Generate Backup” button.
- 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 a 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:
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 to communicate 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:
- Login to your cPanel account and click “MySQL Database”
- Scroll down to MySQL Users -> NewUser
- 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 drop-down. 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:
- Go to the configuration file and select “Edit”
- Search the code for the database name. You will see something like this:
- the database name will contain your new cPanel name in first part. Change the first part before the underscore and leave everything else unchanged.
- Set the database username and password.
- Save the file.