Today we feature a guest post by Justin Stanley, a database administrator and freelance writer. Check out his occasionally-updated blog at neverbeencool.com or follow Justin on Twitter.
Look, here’s the deal. At some point in your blogging life, something is going to go wrong with your site.
Maybe it’ll be something small. Like that time you turned your back for two seconds to endorse a couple royalty checks and your cat ran across the keyboard, deleting your most popular post.
Then again, it could be something huge. Like the-government-has-to-nuke-your-hosting-company’s-town-from-orbit-to-contain-the-zombie-apocalypse huge, something that leads to the annihilation of an entire zip code… and, more importantly, your WordPress site.
So what’s a blogger to do? Well, for starters, he makes backups.
I know, I know. Making backups is about as sexy as getting hit in the head with a hammer while watching Rush Limbaugh reenact that Michelle Pfeiffer “Makin’ Whoopee” number. Besides, your hosting company backs up all its servers nightly, right?
Well, yeah. If they’re worth one red cent of your hard-earned money, they better be backing up all user data pretty damn frequently. And they better be taking those backups offsite regularly in case Bill in accounting leaves his popcorn in the microwave too long again and the entire building goes up in flames. But that doesn’t necessarily cover you. First off, most hosting companies will need at least a couple days to restore those files for you. Can your business afford to be without its web presence for that long? And what happens if the hosting company goes under? I think I’ve heard something about the economy having a problem or two lately…
Point is, you need to be responsible for your own backups, and you need to backup everything often.
Right about now, I’d bet you’re asking yourself a couple of questions:
- How often should I backup my WordPress site?
- Assuming you won’t do it for me out of the kindness of your heart and love for your fellow man (I won’t), how the Hell do I back up my WordPress site?
The answer to Numero Uno is… “it depends.” How often do you post to your site? Daily? Weekly? A daily backup seems like a waste of time if you’re only adding new content once a month. Likewise, backing things up annually when you’ve been known to post 5 times a day will almost certainly lead to tears, booze, and much cursing. It all comes down to how many days worth of posts and comments you could live with losing if the aforementioned zombie apocalypse came to town tomorrow.
And that brings us to number two, which, obvious poop jokes aside, is probably what brought you here.
Now, the problem with writing a How To guide about WordPress backups is that there’s no way to possibly cover every hosting situation out there. Some of you may have SSH access and be command-line ninjas while others may only recognize “SSH” as letters in the English alphabet. So before we get too far into this, let’s make a couple of assumptions:
- You have FTP access to your site and an FTP client you know how to use.
- You have access to cPanel/phpMyAdmin (or some other MySQL admin tool that you can use by yourself).
OK. Let’s back stuff up. Since this is a in depth set of information, read more after the jump:
WordPress Database
When you first installed WordPress, you were asked to create a MySQL database WordPress can use to store most of the content and settings associated with your website. Every time you write a post and hit that Publish button, WordPress inserts all your brilliant prose into that database and fetches your words back out when someone visits your site. Well, now that we’re talking about backing up your WordPress site, guess which is the most important piece of the puzzle?
The majority of web hosts today give their users access to an application called phpMyAdmin, usually accessed through an interface called cPanel. If you browse to the cPanel page provided by your host, you’ll probably see an icon for phpMyAdmin in a Databases section that looks something like this:

Once you open phpMyAdmin, the backup process is pretty simple:
- Click the Export link.

- On the “View dump (schema) of databases” page:
- Click the name of your WordPress database and make sure the “SQL” radio button is selected in the Export window:

- Check “Save as file” and click Go:

- Click the name of your WordPress database and make sure the “SQL” radio button is selected in the Export window:
After you hit Go, phpMyAdmin will start to export your entire WordPress database into a single file (in this case, named “sandbox.sql.zip”) and ask you for a place to save it on your computer. The amount of time required for this step will depend on the size of your blog, the number/type of plugins installed, etc. An established blog with hundreds of posts could take several minutes and spit out a sizable export file.
The good news is that, once you have that file saved, you’re done. Well, done with this step, anyway. After all, the database is just one part of your blog. You still have to backup your…
WordPress Content Files
Not everything you add to your WordPress site is stored in the MySQL database. If you’ve been using WordPress for any length of time, odds are that you’ve switched to a custom theme that you uploaded into the wp-contents/themes directory. You probably added a few third-party tools to wp-contents/plugins, too, amiright? Even images you add into posts (if they aren’t hosted on Flickr or some other external site) are generally uploaded into your wp-contents/uploads folder.
Point is that you weren’t done when you exported your MySQL database. Whenever you do a backup, you need to make sure that you include all these extra files that make your content and site look the way you want.
Remember those assumptions we made earlier, specifically the “we assume you know how to use FTP to move files to and fro” one? Well, this is where that comes in. When you need to make a backup, bust out FileZilla (my personal favorite), Cyberduck, or whatever file transfer app you like and snag everything in the wp-contents folder and all its sub-directories.
WordPress Core Files
This is the stuff you originally downloaded from WordPress.org along with the updates to new versions of WordPress since that time. It probably lives inside either your public_html folder on your webhost’s server or inside a folder called wordpress on the same.
You’ve got a couple different options on this one. You could use your FTP access to copy all these files down to your local machine, or you could just say “frak it” and count on downloading the WordPress files directly from WordPress.org in the event of a future restore. The current version of WordPress is available at http://wordpress.org/download/ and previous versions can be found at http://wordpress.org/download/release-archive/.
Personally, I prefer to back up the whole directory the same time that I backup the wp-contents folder mentioned in the last section. The WordPress install files don’t add that much to the size of the download and, more importantly, it ensures that you’ve got a copy of the version of WordPress that your themes and plugins worth with properly. Remember that not all plugins/themes work with every version of WordPress and, while you could parse through that SQL backup file to figure out which version you were using, it’s easiest just to back it all up at once.
And what happens if, God forbid, WordPress.org itself went away? Or was down when you needed it? Wouldn’t you rather have everything where you need it without having to rely on anybody else?
If you DO decide to risk it, though, at the very least make sure that you download a copy of your .htaccess and wp-config.php files from the base WordPress directory. Otherwise, you might have to spend some time tracking down usernames, passwords, and other configuration information you may not have handy.
Other Stuff
You know, we’re about 1300 words into this brief discussion and we’ve just barely scratched the surface on the different methods a blogger could use to backup his WordPress site. If you’d like to know more, take a look at the WordPress backup documentation. You’ll find some detailed info there about various methods for syncing up your computer with your hosted WordPress site, links to some popular backup plugins, and a screenshot or two taken from other backup-related tools.
No matter how you go about it, though, please please PLEASE for the love of GOD back up your site.
Go.
Do it now.
Photo by lucianvenutian, used under Creative Commons licensing
These other posts might be of interest to you:





