Backing up Wordpress database

I'm an O.C. and a paranoid (bad combination, I know), and I've learned from experience that there's nothing like a good backup strategy to cover your bases.

So I regularly back everything up, but unlike Linus, I don't have a readily available FTP server to do that. I do have a GMail account, though, so that's the next best thing. Below is my script to back up Coredump's SQL database:


#!/bin/sh

DBNAME=database_name
DBUSER=username
DBPASS=password
DBHOST=database_host
EMAIL="[email protected]"
SUBJECT="SQLbackup"

mysqldump --opt -u $DBUSER -p$DBPASS -h $DBHOST $DBNAME > backup.sql
gzip -9 backup.sql
DATE=`date +%Y%m%d`; mv backup.sql.gz backup-$DATE.sql.gz
echo 'SQL backup is attached.' | mutt $EMAIL -s $SUBJECT -a backup-$DATE.sql.gz
rm backup-$DATE.sql.gz


Change the user information above (from wp-config.php), chmod 711 the script, and plug it in crontab like so:

@weekly $HOME/path/to/script >/dev/null 2>&1


In GMail, create a filter to archive the incoming mail from above.

Comments

Popular posts from this blog

Pull files off Android phone