#! /bin/bash
USER=root
PASS=123456
HOST=localhost
BACKUP=/backup/sql
if [ ! -d $BACKUP ]; then
mkdir -pv
$BACKUP
fi
for db in `mysql -u$USER -h$HOST -p$PASS -e "show databases;" | egrep -v "mysql|information_schema|performance_schema|Database|test"`; do
mkdir -pv
$BACKUP/"$db"_`date +%F`
for tb in `mysql -u$USER -h$HOST -p$PASS -e "show tables from $db;" | sed '1d'`;do
mysqldump -u
$USER -h$HOST -p$PASS $db $tb | gzip -c > $BACKUP/"$db"_`date +%F`/"$tb".sql.gz
done
done