[root@AY130828161048465847Z ~]# vi mysqlbak.sh
#!/bin/bash
USERNAME=root
PASSWORD=mysql
DBNAME=test
DATE=`date +%Y%m%d`
MYSQLDUMP=/usr/bin/mysqldump
BACKDIR=/data/bak
${MYSQLDUMP} -u${USERNAME} -p${PASSWORD} ${DBNAME} | gzip > ${BACKDIR}/${DBNAME}.${DATE}.sql.gz