mysql备份脚本
#!/bin/sh
# Database info
DB_USER="111"
DB_PASS="111"
DB_HOST="1111"
DB_NAME="数据库名1 数据库名2"
# Others vars
BIN_DIR="/usr/local/mysql/bin" #the mysql bin path
BCK_DIR="/data/backup/mysql" #the backup file directory
DATE=`date +%Y%m%d%H%M%S`
# TODO
# /usr/bin/mysqldump --opt -ubatsing -pbatsingpw -hlocalhost timepusher > /mnt/mysqlBackup/db_`date +%F`.sql
# $BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME > $BCK_DIR/db_$DATE.sql
for DB in $DB_NAME
do
$BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS -h$DB_HOST $DB | gzip > $BCK_DIR/${DB}_${DATE}.sql.gz
done
00 0 * * * /bin/sh /data/backup/auto-backup-mysql.sh