#!/bin/bash
cat > /tmp/bak.txt <<EOF
mysql
JUN
zabbix
EOF
[ $? -eq 0 ] && echo "Create file success!!!" || echo "Failure to create a file"
DBLIST=$(cat /tmp/bak.txt)
DBUSER=root
DBPASS=000000
BAKPATH=/server/bakup/mysql
for i in $DBLIST
do
[ ! -d ${BAKPATH}/$i ] && mkdir -p ${BAKPATH}/$i
mysqldump -u$DBUSER -p$DBPASS -x -B -F -R --events $i | gzip > /server/bakup/mysql/$i/mysql_${i}_$(date +%F-%T).sql.gz
[ $? -eq 0 ] && echo "Backup $i database success!!!" || echo "Failure to backup $i database"
done