I figured I’d write this tutorial because many people believe that the backup wizard in cPanel can be used to move a site to a new host, when in reality it cannot be used without modifications because it backs up your entire home directory.
For this reason, if you were to restore using one of the backups, you’d end up overwriting your entire home directory on the new hosting account. This would cause many problems because the home directory path would likely have a new name and since the system files would be different, you’d end up with a misconfigured hosting account.
In the video below I show you how I backup and restore my sites using cPanel. Below the video, you can view the key points in case you don’t feel like watching an entire video.
Can’t view the video? Watch it on YouTube
Backup Process
I back up my site’s files using the file manager and I backup my MySQL database using the backup wizard since the backup wizard makes restoring easier than going through phpMyAdmin. As for the emails, I just create the accounts on the new hosting account manually. If you are using subdomains, you can just add the new subdomains manually as well. Just remember to create them prior to restoring the files that belong to the subdomain.
Backup files
So these are the exact steps I take… First I launch the file manager and select ‘home directory’ and have ‘show hidden files (dotfiles)’ checked off.
Once in the file manager, I select the directory that I wish to backup. In this case, it’s the ‘public_html’ directory and I compress it using the ‘compress’ link at the top. I choose ‘zip’ for compression type but you can choose any of the other archive formats. Note that some browsers unarchive files upon download so make sure to disable that feature if your browser has it.
Also note that if your site uses a subdomain which is in a directory outside of ‘public_html’, that you will need to compress and download those directories as well. Also remember to add those subdomains on your new hosting account.
Backup MySQL databases
After backing up your site files, simply go to the backup wizard and backup your MySQL database. Simply go to backup wizard > backup and in the ‘partial backup’ section click the ‘MySQL databases’ link and click the database(s) that you wish to backup. Clicking the databases will automatically generate the backups and download them to your computer.
Now that you have your backups ready, you can start the restoration process on the new hosting account.
Restore MySQL databases on the new host
Go to your new cPanel and start by restoring the MySQL database(s). Simply click on the backup wizard link and then click ‘restore’ and then click on the ‘MySQL databases’ link. Next you will need to upload your backup. The filenames should end in either ‘.sql.gz’ or ‘.sql’.
After you’ve restored your MySQL databases, go back to the cPanel home page and click on the ‘MySQL databases’ link. On this page you will see your new databases.
Note: if your cPanel username has changed, your MySQL database prefix has changed as well. If this is the case, you will need to edit the configuration files of your application with the new database credentials. If you are using a CMS such as Magento, Prestashop, WordPress, Drupal etc., you can figure out how to do this by simply doing a web search.
Next create a user for your database. Again, if your username and password differs from your old one, you will need to change this information in the configuration file(s) of your CMS.
Restore site files
Now that you’ve restored your databases, you can proceed to restoring your site. I simply launch the file manager and again choose ‘home directory’ and make sure that ‘show hidden files (dotfiles)’ is checked off.
Then I move to my ‘public_html’ directory and upload my zipped public_html backup that I created earlier. I then unarchive the file and move the unarchived files from within the decompressed ‘public_html’ directory to my main ‘public_html’ directory. After moving the files, you can delete the empty ‘public_html’ directory, but make sure not to delete the main directory by accident.
If you have other directories that you’ve backed up which were outside of the ‘public_html’ directory, you can restore those directories by uploading the archived files directly to those directories and follow the same steps that were taken for the ‘public_html’ directory.
Post restoration checklist
After you’ve restored your site, make sure that your folder permissions are correct.
If your database credentials or database name has changed, remember to add the new values to your apps configuration files.
Since some apps have the home path specified in a configuration file, check whether your home path has changed and whether your app needs you to specify this new path. Again, do a web search to figure out the location of your apps configuration files and look through them.
If you had subdomains on the old hosting account, remember to add them to the new hosting account.
Remember to recreate your email accounts and forwarders.
Once finished, simply launch your site in your browser to see if it’s working properly.