#!/bin/sh
#		  /usr/local/bin/backup-mysql
# http://crystalfaeries.net/posix/bin/backup-mysql
# celeste:crystalfaery 2013-05-25 19:02:50+00:00

if [ \! -d		/var/cache/rsnapshot/ ]
then 
	mkdir -p	/var/cache/rsnapshot/						||	exit	1
fi
if [ \! -d		/var/cache/rsnapshot/hourly.0 ]
then 
	mkdir -p	/var/cache/rsnapshot/hourly.0					||	exit	2
fi
if [ \! -d		/var/cache/rsnapshot/hourly.0/`hostname` ]
then 
	mkdir -p	/var/cache/rsnapshot/hourly.0/`hostname`			||	exit	3
fi
if [ \! -d		/var/cache/rsnapshot/hourly.0/`hostname`/automysqlbackup ]
then 
	mkdir -p	/var/cache/rsnapshot/hourly.0/`hostname`/automysqlbackup	||	exit	4
fi
/usr/bin/mysqldump -u root -p`cat /etc/mysqlkey` --all-databases | mcrypt -f /etc/darkey -z > /var/cache/rsnapshot/hourly.0/`hostname`/automysqlbackup


syntax highlighted by Code2HTML, v. 0.9.1