How to Backup and Restore a WordPress Database

Yesterday afternoon a self hosted wordpress blog I maintain died. It just wouldn’t load and then the site would timeout. The database had decided to pack it’s bags and vanish, not even a dear john letter, a note telling me why. A quick communication with support and the quickest option was for me to restore from a backup. Here is the why, where and how rough guide, not too detailed, like a birds and the bees conversation really.

First of all the precaution bit. You could go through phpmyadmin to make backups or….. install the wunderbar wordpress plugin that is called ‘WordPress Database Backup’ over at: http://ilfilosofo.com/blog/wp-db-backup/ . You unzip and  upload the directory to the ‘plugin’ directory in the  ‘wp-content’ directory via wordpress. Then login to your wordpress installation and via the ‘plugins’ option activate.

Next you need to select ‘Backup’ from under the ‘Tools’ menu. It will probably mention a directory needs to be writable. Fair enough it creates a random directory name, so again via ftp you can make it writable. My favourite ftp application by the way is filezilla and you right click on a directory to change write permissions.

Okay that’s the configuration done and via the very same ‘backup’ page make a backup. Now you can sit there satisfied that you’ve made a backup. Well done you. Wait there is more to it than this! There are different ways and one option is for scheduled backups, sent to you via email. Excellent as automation is usually best when it comes down to backups.

The Restoration

Unfortunately unless you plan on migrating your database, you will need this backup for…. restoring. Yes the moment where something corrupts, gone horribly wrong and you need to restore it pronto. Sweating, pondering the idea you’ve lost all the work, the time and effort…okay I’m being over dramatic here.

Now what I do is create a new database, add a new user and then access it via phpmyadmin. Phpmyadmin usually can be found via your web hosts control panel. Then there is a nifty import option. Just select the backup file you made with the wordpress backup plugin and import. Hopefully et voila!

Now you need to download via ftp your wp-config.php file from the root of your blog directory. i.e. same place the index.php file is found. Open it up (my preferred windows app is notepad++) and then edit it. Simple replace the database name, location, username and password with the new details and reupload the file.

Hopefully your wordpress blog is up and running again. Obviously you follow these instructions at your own risk. There could be further recommendations for different scenario’s, other than the one I went through. So don’t hesitate to leave a comment and I hope this rough guide helped someone, maybe not today, but for a beautiful tomorrow…. over dramatic again? Yes, but not for me, not today after a restoration saved a years worth of work.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments