Last week, I had a major freak-out when my blog suddenly became inaccessible. There was nothing wrong with its WordPress install, but the MySql database behind the scenes was stuck – I couldn’t access it via phpMyAdmin or SSH – breaking my blog completely and leaving me helpless.
While this was happening, I kicked myself for not backing up in the past few months, and sadly wondered if I would have to create a new database and recreate posts from scratch.
I eventually contacted my host (I don’t know what they did) and they got things working again – now all is well.
But my panic was a wake up call – a reminder that it’s important to back up your blog’s database – where all the posts you write actually reside. The files within your WordPress directory contain the code that serves up the pages, the themes, and plug-ins. But the heart of the blog – the actual content made up of hundreds of posts – is stored in a MySQL database that lives only on your server.
Backing up this databasemeans getting a “MySQL Dump” of your blog to your local computer. Here are instructions for blogs hosted on WordPress.com, using a database manager like phpMyAdmin.
If things get really dire, you may need to initiate the MySQL backup through a command line, or SSH. You’ll need to know the name of your database, the login and password of the MySql database containing your blog. These are located in the wp-config.php file in your WordPress directory. Instructions can be found at the WordPress Codex.
Either method will give you a file named databasename.sql.gz – which literally contains all the content of your blog in compressed form, plus the MySQL commands necessary to recreate the database if need be. You can upload this file into an empty MySql database, essentially restoring your blog.
You can also install WordPress plug-ins to make back ups easier, or even automatic:
WordPress Database Backup: Il Filosofo
Upstart Blogger has a good summary of the steps involved.
Yes, some of this technical information made my eyes glaze over, too. But just imagine the horror of your entire blog vanishing into thin air as some subtle motivation.
In the absence of a database back up, Google might help to recreate some old posts. You do a search for site:(your blog url) and then click on the “Cached” links to see what exists in the Google cache. You could also dig through your RSS feeds. But obviously, recreating an entire blog using either method would be a time consuming and tedious chore.
Backing up your blog through a MySQL dump takes advantage of functionality that’s built into your web server. So back up your blog today!