Uh oh! I am sorry to hear that your WordPress site is not very well!
Don't worry this tutorial will help you to restore it.
We have covered how to backup your site in a previous article. Make sure you follow that to understand the backup options you have.
If you followed that article or you have backups that use the same techniques then, you have a backup with either a:
If you have any of these backups then we can restore your site.
Let's get started.
What is a WordPress Backup
Before we dive into how to restore WordPress we need to make sure you have the right backup files. There are two types of backup files for WordPress:
The files - this includes the themes, plugin and media
The database - this includes the posts, comments and settings
To do a full restore you need both sets of data. Always back up the files and database at the same time and restore them both together.
Many actions that you perform on WordPress will create files and database changes. For example, a new plugin will add files and database settings to WordPress.
If the installation goes wrong you may find that you need to roll back to the last backup. To remove the plugin completely you will need to do a file and database restore.
When might you need to restore WordPress from backup?
There are many reasons why you might need to restore WordPress. We have already touched on how a plugin installation can cause WordPress to break. Here are some of the other common reasons you may need to restore:
Upgrading WordPress - When you update the version of WordPress that is running on your site.
Installing a plugin - A plugin will add files and update the database
Upgrading a plugin - Upgrading a plugin will do the same
Installing a theme - A theme will add new files and change the config settings in the database
Adding custom code to areas like functions.php - Be careful of adding custom code to functions.php
Comments spam - I have seen WordPress stop working when spam has overloaded the server. Make sure you have the spam filter Akismet plugin installed
Always do a backup before you do any of the above so that you are ready to restore if something goes wrong. The backup should include both the site files and the database.
Next, let's look at how to do a restore using the 3 methods:
Use your hosting provider's backups
Restoring a backup using UpdraftPlus plugin
Restoring a manual backup using cPanel and phpMyAdmin
Let's start with the hosting provider.
Restore WordPress using Hosting Provider backups
Your host will make backups of your site. There are three types of backups that your hosting provider will give:
System backups which include your site that you may be able to request via customer support
They create automatic backups as part of the paid plan of your site
They give you a tool to create your manual backups
Options 2 and 3 will allow you to perform a restore of your site. Let's look at Kinsta as an example.
As part of the Kinsta paid plans you get daily automatic backups. You can create manual backups as needed. These backups last for 14 days.
To restore one of these backups you can log in to the Kinsta dashboard and select “Sites”. You can find the backups on the “backups” tab and you will see the backups listed. To restore a backup you can select “Restore to” and select the site:
Most hosting providers will have a similar setup. Here are some common hosting providers and their restore instructions:
Once you open the settings scroll down to the list of backups that you can install:
Select the “Restore” button on the backup that you would like to restore. You will then see a screen asking you what you want to restore:
For this example we are going to do a full restore, select all and click “Next”. You may see a warning like this:
The PHP setup on this webserver allows only 30 seconds for PHP to run, and does not allow this limit to be raised. If you have a lot of data to import, and if the restore operation times out, then you will need to ask your web hosting company for ways to raise this limit (or attempt the restoration piece-by-piece).
This warning can be a bit worrying at first. If you have a very large site that has been running for a few years then the timeout may happen. In this case, you can increase the timeout on your site by adding this line to your .htaccess file:
php_value max_execution_time 300
If you are not comfortable doing this yourself then you can ask your hosting provider. They need to increase the max_execution_time size on your site.
Setting the value to 300 has increased the timeout to 5 minutes and now the warning is gone:
The restore will then start to process and can take a couple of minutes to complete. You may see an error during the restore. A common error is with permissions with an error like this:
Error message: Could not copy file.
This error shows when it has had trouble creating a file:
You can attempt to fix the permissions yourself using the File Manager. A link to the File Manager will be in the cPanel or admin area for your site. Yet, this is not an easy thing to fix.
If you get a permission error then contact your hosting provider. Explain to them the permission problem when doing a restore using UpdraftPlus. They will be able to help set the correct permissions for you.
Once the permissions are correct you will see the successful restore screen:
The restore is now complete!
If this did not work then our last option is a manual restore, let's look at this next.
Restore WordPress files using cPanel and File Manager
In the File Manager, we selected all the files and folders inside the public_html folder. We then created a zip file as a backup.
You can use this Zip file to restore your site files.
To do that open File Manager again:
Then find the backup zip file:
To restore this file we need to extract it and replace the existing files. The first step is to find your public_html directory. Then rename it to public_html_old. This will stop your site from working so you will want to do this during a quiet time when you have little traffic.
Then you need to extract your zip backup (upload it first if it is not already on the server). Right-click the zip file and choose extract:
Then extract the zip file to the ./public_html folder:
Now the public_html folder is back and the website will be working again.
Next, we need to restore the database.
Restore WordPress database backup using phpMyAdmin
With the files updated we now need to restore the database. You must have a backup .sql file to restore before you start. This file must have the database structure and data inside it. For more on how to do this check the manual backup section on how to backup a WordPress site.
To restore the backup you use a tool called phpMyAdmin. It will also be in cPanel or the admin area of your site:
When you click to open phpMyAdmin you will see a screen like this:
The database has many tables. To restore them from the backup you need to “drop” the tables. Word of caution here! This is a dangerous task, you are about to delete all the tables in the database!
If you are not comfortable then stop! If your restore does not work you can lose everything so please proceed with caution.
If you are ok with the risk (you maverick!) then let's continue! Click on your database on the left-hand menu. This will open up the “Structure” tab showing all the tables in the database:
Scroll to the bottom and select “Check all” and then in the dropdown select drop. You will then see a warning like this:
Select Yes to delete the tables. Once you have done this your website will not be working. The next step is to restore the backup. Select the “Import” tab:
Click on the “Choose file” button and then select your backup file. This is a .sql file that has all the tables and data inside. Choose this file then scroll to the bottom and click on “Go”.
In a few moments, the restore will be complete and you will see a success message like this:
You can then check that the tables are back by selecting the database in the left-hand menu:
Congratulations, you have restored the WordPress database.
Wrapping Up, How to Restore a WordPress Site
Restoring a WordPress site is a very technical task and it is not without risk. We have covered how to restore a WordPress site using three methods:
The restore methods get more technical as you move down the list. If you can, then use your hosting provider backup, this is the least risky option.
We also looked at when you may need to do a restore. Some of the common causes of issues on a WordPress site are:
Installing a plugin
Upgrading a plugin
Installing a theme
Adding custom code to areas like functions.php
Always do a backup when doing one of these actions so that you can restore when needed.
We covered how you can restore using some of the common hosting providers: