New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Restoring your site

From: WordPress 3: Developing Secure Sites

Video: Restoring your site

In this screencast, we're going to restore a WordPress site that, for whatever reason, has crashed and lost a bunch of data. The only solution is performing a full site restoration, which includes both the database and the physical files. The restoration process takes some time, but conceptually is very straightforward. Here are the basic steps. First, obtain the most current version of your backup files. Second, set up a temporary maintenance page telling visitors that you'll be back soon.

Restoring your site

In this screencast, we're going to restore a WordPress site that, for whatever reason, has crashed and lost a bunch of data. The only solution is performing a full site restoration, which includes both the database and the physical files. The restoration process takes some time, but conceptually is very straightforward. Here are the basic steps. First, obtain the most current version of your backup files. Second, set up a temporary maintenance page telling visitors that you'll be back soon.

Third, upload the new files. Fourth, restore the database and lastly, remove the temporary maintenance page. To do this, we will need an FTP connection for the file upload and an app to work with the database. A very popular, well-documented, and open-source app is phpMyAdmin. If it's not, ask your host for help finding an alternative. In any case here is what our WordPress database looks like using phpMyAdmin. All of our tables are listed here in the left, and we have options to do just about anything we need to do with the database.

So with this open and ready to go, let's return to our FTP editor and set up the temporary maintenance page. First, grab a copy of the maintenance.html file that's included with the exercise files and upload to your server. If you don't have the exercise files, copy this code the best you can, and that should work just fine. You want to save the file and upload to the server, like so. Next, place a copy of the blank htaccess file--also included in the exercise files-- place it in the root directory of your site, open it, and then paste in the htaccess code that's also included with the exercise files.

Save the file and upload it to the server. We do need to make sure that the IP address matches your own. Return to the browser and type in 'what is my IP?' in Google. That will take you to a page such as this where it lists your IP address right upfront. Grab a copy, return to the editor, and replace the IP address with your own, and save the file and upload it to the server.

This will ensure that you have access to your site while everyone else is redirected to the maintenance page. To see this in action, let's go to a proxy server, such as the one at proxy.org, and we'll try visiting our site using a different IP address other than our own. We enter the URL, click on the Go button, and we see our maintenance file in effect. The redirect is working and everyone except for us will see this message. This means that we can work on the server in a relaxed fashion, without worry that visits might be interrupted.

So with the maintenance page in place, we're now ready to begin the site restoration process. Because file uploading takes the most time, we'll get that started first. Return to the FTP file editor and we are connected to the server. As you can see, besides the maintenance.html file and htaccess files, all files have been removed, leaving us a clean slate to work with. Note that if you have large collections of non-WordPress files on the server, such as image files or video uploads, you'll save time by not deleting them; however, part of the restoration process is to start completely fresh and eliminate any hacked files. So it's your call.

If you do decide to leave the files on the server, just make sure to check them thoroughly for anything unexpected or unusual. That said, let's begin the restoration process by uploading our backup files to the server. We select all of our files and click the Upload button to go. It is totally okay to replace the existing htaccess and maintenance.html files. Let's click Replace, and while that's happening, let's go back to phpMyAdmin to restore the database.

Here in the phpMyAdmin app, we are looking at the WordPress database, and the first thing we want to do is delete all traces of the previous database by clicking Check All and then selecting Drop from the dropdown menu. It will ask you if you really want to do this. It's a big move, and you do. We have a backup of the database, so we want to delete everything in this database. Here we see that the tables have been dropped. Everything is ready to go for a fresh import of your backup database.

So to do this, click on the Import tab at the top of the page. Then browse to the location of your most current backup and leave everything else set at the default settings. Finally, select Go to upload the database. It can take some time for large files, but a default WordPress database should go pretty quick. And as seen here, our database is now restored to the most recent backup. Let's return to the FTP/file editor and check on those files. And we're all set.

At this point, all files have been uploaded to the server, as you can see here, and the database has been completely restored as well. So let's return now to the site and see if it works. Refreshing the page. Yes, it's working great. From here, it's just a matter of going through and making sure that everything is working. Check as much as you need to be convinced that the site has been fully restored. Maybe you want to log in to the admin area and take a look around, check posts and pages, and so on.

Once everything is running smooth, let's go ahead and delete the maintenance.html file and remove the htaccess code that we added to redirect site visitors. We now want them to enjoy full access to our restored site, so we can just delete this and upload the file, and for the maintenance page we need to go to the server and just delete that from the server like so. And with that, normal traffic should be flowing once again through our site.

We can hit Refresh and then visit the proxy site again one more time to see what happens when someone from a different IP address tries to request the site. There it is, and I have the WordPress directory right here, and it looks like it's just fine. In the screencast, we've completely restored our WordPress site, using our most current set of backup files. We covered an excellent method of keeping good backups in the previous screencast, so be sure to check that out too.

Show transcript

This video is part of

Image for WordPress 3: Developing Secure Sites
WordPress 3: Developing Secure Sites

36 video lessons · 11193 viewers

Jeff Starr
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.