Restore a WordPress backup
On a previous article we covered the steps you must take in order to make a backup of your WordPress website, now is time to restore that backup on a local Linux CentOS 7 Virtual Machine, on which a fresh install of WordPress was done, this way you’ll see a copy of your website running on local machine, in my opinion the best way to verify the good health of your backup.
Step 1 – Copy .gz file into the website’s root folder
The first step is to copy the backup you’ve previously made of the “wp-content” folder into the local website, you can use your preferred FTP/SFTP tool to complete this task, we’re going to use WinSCP, see below screenshots.
Step 2 – rename the wp-content folder
Before proceding to unzip the folder you must change the name of the local “wp-content” folder that is there empty as part of the fresh installation of WordPress, this one will be replaced by the one on the .gz file.
The WinSCP GUI allows you to rename a folder in the same way you would do in Windows, select the folder and press F2.
Step 3 – Unzip the .gz file
Another useful feature of WinSCP is the UnTar/GZip tool that you can use to uncompress and untar, both tasks at the same time, see below screenshot.
You can check inside the “wp-content” folder to make sure your files are there and after that, if you want you can delete both the .gz file and the original folder, the one that was renamed as “wp-content.old”.
Step 4 – Use phpMyAdmin to select the Database
If you have followed our articles you’ll be able to use the GUI provided by phpMyAdmin to select your website’s database and after selecting all its tables, drop them all with just one click, see images below.
This database belongs to a fresh install of wordpress that was created as the place where your backup will reside, and as such their tables are completely empty.
Step 5 – Select all tables
The idea here is to remove all the tables before importing the ones in the “*.sql” file, once you’ve selected the target database you must put a check mark on the “Check All” checkbox, see image below.
Step 6 – Drop all tables from Database
Once all the tables are selected you can proceed and drop them all, drop is the equivalent to delete/remove.
Step 7 – Import .sql file
You probably remember that one of the tasks completed when creating the backup of your website was to download the “.sql” file using the GUI provided by phpMyAdmin, see this article for additional details.
Now is time to complete the same task the opposite way, that is to import the “.sql” file.
Step 8 – Change URLs
The last step is to adapt the website URLs to work in a local environment, this task must be done on the following two places:
Where to go next?
Now that you have a local copy of your website acting at the same time as your website’s backup you can change the URLs in your local copy to point to the local path, take a look at the following article to learn how to achieve this goal.