Join Jeff Starr for an in-depth discussion in this video Restore your site, part of WordPress: Developing Secure Sites .
- [Narrator] In this video, we're going to restore a WordPress site that for whatever reason has crashed and lost a bunch of data. We'll use our demo site to illustrate this. As you can see here, the site is no longer functional. The only solution is performing a full site restoration which includes the files and database. The restoration process takes some time but conceptually, is very straighforward. Here are the basic steps. First, we want to get the most current versions of our backup files and database. Then, we want to set up a maintenance page to let visitors know that we'll be right back.
Next, we'll upload the backup files, restore the database, and then we want to test everything for proper functionality. Last, but not least, we'll remove the maintenance page to allow visitors to return to the site. To perform these steps we'll need an FTP connection to upload our files and an app to work with the database. A very popular well-documented and open-source app is phpMyAdmin. phpMyAdmin is preinstalled on most servers. If you don't see it, ask your web host for help.
Using phpMyAdmin, let's take a look at our existing WordPress database. Remember, our demo site has been compromised so we want to replace this database with a current backup. So at this point, our backup files are ready, phpMyAdmin is open, and our FTP client is connected and ready to go. Let's continue by setting up a temporary maintenance page that will keep visitors from interfering with the restoration process. We do this in two steps. First, open the htaccess exercise file that's included with this tutorial.
We want to copy the code and then paste it into our site's root htaccess file before any WordPress-specific rules that might be in place. Next, we want to change the IP address to match our own. To get this information, we can ask Google, "what is my ip". We can then copy the IP address and return to our file editor and then replace the existing code right here. After adding our IP address, we want to save the file and upload it to the server.
If you have other IPs that you would like to allow, you can include them with additional lines, like so. For this tutorial, we only need one IP, so we'll go ahead and leave it like this. We then save and upload the file and we are ready to go. Once the htaccess maintenance code is in place, it will allow our IP address to access the site while displaying a We'll Be Right Back message to all other visitors. Let's see this in action by visiting our site using a proxy server. Any proxy server will do so for this tutorial we use the one at hide.me We enter the URL of our demo site and clicking the go button, we get a 503 response.
This shows us that the maintenance code is in place and working properly. So we're now ready to begin restoring our WordPress site. Because of the file upload requires the most time, we'll get that started first. Here we are in the FTP client connected to our site on the server. As you can see, we have our backup files here ready to go on our local machine. Then here on the server, all files except for htaccess and cgi-bin have been removed. This leaves us a clean slate to work with. So let's begin the restoration process by uploading our backup files to the server.
We select all files, right-click, and select Upload. For more information on keeping good backups, check out the previous video in this tutorial series. While the files are uploading, let's go ahead and restore the database using phpMyAdmin. The first thing we want to do is remove the current database by Checking All and selecting Drop. Then we click Yes to confirm. Next, click on the Import tab near the top of the screen.
Then click Choose File and locate your database backup. Go ahead and leave all these other settings at their default values unless you have reason to change them. Finally, click the Go button to upload the database. The import process can take some time for large files but a default WordPress database should go pretty quick. And we're all set. We've just restored the most recent backup copy of our site's database. Let's return now, to our FTP program and check on our file upload.
And the upload is complete. At this point, all files have been uploaded to the server and the database has been completely restored. So let's return now to our demo site to see how it all looks. We refresh the page and success. Our demo site is back up and running. From here, it's just a matter of going through and verifying that everything is working normally. For example, you might log into the admin area, check out some posts and pages, the media library, and so on. Once we verify that everything is running smooth, we can remove the htaccess maintenance code to allow normal traffic to return to the site.
Simply remove the code, save changes, and Upload to the server. Then one last check via proxy to confirm that other visitors have access. And yes, we are able to access the site via proxy so we're officially back online and open for business. In this video, we've completely restored our WordPress site using current backup files. We cover an excellent method of keeping good backups in the previous video, so be sure to check that out for more information.
- Backing up and restoring your site
- Setting up strong passwords
- Understanding users and roles
- Choosing trusted plugins and themes
- Changing and recovering passwords
- Configuring authentication keys
- Securing the login page
- Fighting spam in the comments
- Blocking access and detecting hacks
- Building a firewall for WordPress
- Detecting and blocking bots
- Auditing your WordPress security