Wordpress backups
Dave | February 11, 2009My Wordpress is only a few days old but logging in on the admin dashboard showed a new version of Wordpress is out. I was going to sort out backups a little later but now seems a very good time to do it and then I can do the upgrade.
The Worpress site has a section on backing up Worpress , basically you backup the database and backup the flat files in your Wordpress HTML directory.
First create a directory to store the backups :-
mkdir -p /backups
chmod 700 /backups
To backup the Wordpress database I created a little script in /usr/local/bin :-
#!/bin/bash
TODAY=`date ‘+%Y%m%d’`
DBNAME=wordpress
DBPASS=wpdbpasswd
DBUSER=wpdbuser
mysqldump –opt -u ${DBUSER} ${DBNAME} | gzip > /backups/wordpress.dump.${TODAY}.gz
————————————————————————————————————-
The values for DBNAME , DBPASS and DBUSER are those setup in the wp-config.php file for your install.
To backup the flat files I just did a tar :-
cd /var/www/html ; tar cvf /backups/my-wordpress.20090211.tar wordpress
Of course no one cares about backups – only restores count, so you should test your restore on another server. You should also backup the Mysql database which holds the usernames and passwords
mysqldump mysql -p > /backups/mysql.db.dump.20090211
You will be prompted for the root user password for the Mysql database which you would have set when you first started up mysqld at install time.
Don’t forget to copy the dumps and tars to another server in case of a total server loss !
I will automate all the above with cron and rsync in the future





