/bin/sh: Backup Wordpress to Gmail

The code below was written pretty quickly. It backs up the Wordpress directory, the mySQL table, zips it then emails it to the specified gmail account. Mutt must be installed.. change the variables to suit your environment.

#!/bin/sh theDate=`/bin/date +%Y%m%d`

######### backup DB ########## /usr/local/bin/mysqldump -A -u root --password=myPass > /tmp/mysql-${theDate} cd /tmp tar -czf mysql-${theDate}.tgz mysql-${theDate}

######### backup wordpress dir containing all blogs ########## cd /www tar -czf wordpress-${theDate}.tgz wordpress mv wordpress-${theDate}.tgz /tmp/

######### send mail (10MB limit so send individual emails) ########## ######### (also throws in a copy of httpd.conf for good measure) ##########

mutt -s "mySQL backups (${theDate})" -a /tmp/mysql-${theDate}.tgz [email protected]> /dev/null mutt -s "wordpress backups (${theDate})" -a /tmp/wordpress-${theDate}.tgz -a /usr/local/etc/apache/httpd.conf [email protected] > /dev/null

######### cleanup ##########

rm /tmp/mysql-${theDate} rm /tmp/mysql-${theDate}.tgz rm /tmp/wordpress-${theDate}.tgz