Sometimes bad things happen to good people websites. It’s not fair, but it’s true. And one of the worst things that can happen to your website (specifically your WordPress website) is that your posts go poof. Gone. They’re outta here like a home run at the World Series. And you, of course, are the one who has to find some way of WordPress database recovery to bring them back from whatever limbo dimension they currently exist in.
Never fear, Divi Nation, that’s not nearly as hard (or as complicated) as it sounds. WordPress, thankfully, is set up to make this process as painless as it can be. Think about WordPress database recovery as stubbing your toe, while other software’s db recovery options are more like breaking your toe–not the worst thing that could happen, but definitely not something you’re eager to experience.
Like almost everything else around here, WordPress database recovery comes in two primary flavors: use a plugin or do it manually.
WordPress Database Recovery via Plugin
Let’s start with the simpler option. Hopefully, you have a backup plugin running on your site. If you don’t, go grab one. My personal favorite is UpdraftPlus. It’s what the cool kids call good stuff. There are lots of other plugin options out there, too, like BackWPup or All-in-One WP Migration. Heck, even Jetpack offers you backups.
But we’re gonna use UpdraftPlus because I like it.
Make the Backup to Restore From
Under the Settings menu in your dashboard, you now get an UpdraftPlus Backups option. Navigate there, and you’ll see this:
Before you can restore your database, you have to back it up. So click, obviously, the Backup Now button to perform a one-time backup. The really important one is that the database is included, but I highly suggest backing up everything regularly.
Fast Forward to Disaster Day
Oh, no! Your posts! They’re gone! The website is a blank, desolate wasteland of blankness! What ever will you do?
Restore that backup, that’s what! Hit the Existing Backups tab and get ready to get everything back under control.
Once that’s done, you’ll get a modal window that asks you what you want to restore. If your posts are gone, make sure you click database, but if you’re totally blank, give em all a go.
Please note that if you don’t see the restore button, you’ll need to upload the backup from before (which will be easy because you totally downloaded it or sent it to remote storage, right?).
You’ll get another modal after this telling you the files have been pulled and are being restored, which will eventually lead you to this magnificent sight:
Ain’t that just the most beautiful sight you ever did see? When you’ve finished restoring all the backup files you need, your site should be back to normal.
The Old Fashioned Way
Nobody–yep, nobody! Fight me!–likes to dig around in MySQL unless they have to. But you can–and if things go truly wonky on your site, you might have to.
The first thing you’ll want to do is head into phpMyAdmin. If you aren’t familiar with it, you can get there from your cPanel.
When you’re inside, you will probably be a little overwhelmed if you’ve never done this before. You can make a backup of your db here, too, by going to the Export tab after selecting which DB you want to save. It will just save as a .sql file to your computer.
(Note: you should totally do this step regularly as a precaution, too. Backing up your database is a good habit.)
Here’s the Scary Part
Well, it’s the kind of scary part. Once you’ve got your database exported, you’re gonna have to clear out the old one. Yikes. I know, right? But there’s something obviously wrong with it, else you wouldn’t be doing this at all, you know?
So head back to the db itself, pick the database you need to restore, check the box to select everything in there, and get ready to do what every admin has nightmares about: drop all those tables. To the ground!
Once you’ve confirmed (but hitting ok on the next screen) that you are totally and completely obliterating the existing database (not to put too fine a point on it, or anything), you will see this:
Congratulations! You have no WordPress database!
Putting the Pieces Back Together
This is really the easy part of the whole thing. Since you’ve got the downloaded .sql file or the backup from a plugin like UpdraftPlus, you can just import that through phpMyAdmin, pretty much the same way as you destroyed it.
Hit Go, and you’ve saved the day. Once that import is finished, the databases have been restored, and you have totally put Humpty Dumpty back together again. Congrats for real this time!
Bonus: Writing is Revision (History)
One thing that WordPress is awesome about is keeping copies of your revisions of posts for you to revert back to at a later date (and to compare changes). Every time you update, save a draft, or WP does an autosave, a revision is created. You can check that to see if something is amiss, too, before doing a full WordPress database recovery.
From personal experience, I can say just giving a couple of revision histories has really saved me some trouble over the years.
Don’t Fret Your Pretty Little Head
It’s a big deal when something goes wrong. I know that. But there’s no reason to freak out–okay, maybe there’s a few reasons to freak out, but if you stay calm and follow the right steps, there is a good chance that no lasting damage is going to happen to your site.
So whether you got hacked, a new teammember (or an old one!) made a boo-boo, or the universe just decided that you were the one it wanted to put through the wringer that day, you now have all the tools you need for complete and total WordPress database recovery.
Be safe out there, Divi Nation, the official Divi podcast.
Article thumbnail by MSSA / shutterstock.com
Great Article right here. I have the exact same problem as Schona described above and my Google-Fu so far has left me hanging.
I basically have a ‘new’ blog and an old one saved from a couple of years ago BUT only as a .sql file or .sql.qz, I don’t want any of that old blog or the looks but I somehow want to access the old articles there and maybe update them and publish them on the new blog, however the WordPress importer (where I could import just the articles I believe) only accepts a wxr forma (.xml) to do so. I am lost.
With Adminer if I try to import the .sql file nothing much happens to my new blog and I am kind of glad I haven’t lost 2 years of new articles.
Would you have any suggestions for this kind of problem or a solution?
Great post! I want to import my old #wordpress blog which is a sql file into my new blog which requires wxr format. How can I convert it? I don’t want to delete my current posts just migrate the old posts into the blog but I deleted the blog a few years back & only have the sql back up file.
I have uploaded my sql file to my database and I see my old posts but they are not showing up on my blog at all?
A few years back I’m backup sites manually because I don’t trust backup plugins. And now I’m using both manual and plugin methods. Both are working really good for me. Thanks for listing good backup plugins.
Thanks BJ, the moment I saw this post title, I thought Oh god, should we be expecting something to go wrong….. LOL then I noticed Updraft backup plugin, of course a reminder to back up ! I’ve been using Updraft for years, you are right it’s really good, bombproof and trustworthy!
Thanks for the reminder to back up, although I’m on auto back up, It is a very good reminder to always back up a whole website regularly.
Just make sure that if you’re on autobackup (which is the way to go) that nothing gets messed up and it stops running. I’ve had that happen before, and it was lucky nothing happened that I lost a whole site. 🙂
It’s always good to check on the status, just in case.
thanks alot B.J.keeton updraft plus it is my favurite way
Me, too! 😀 #greatminds