#!/bin/bash
MYUSER="root"
MYPASS="123456"
HOST="localhost"
BACKUPDIR="/backup_mysql"
DATE=`date -I`
RETENTION=20
#MYSQLDATA="/var/lib/mysql"
[ ! -d $BACKUPDIR/$DATE ] && mkdir -p $BACKUPDIR/$DATE
DBS=`mysql -u$MYUSER -p$MYPASS -Bse "show databases"|grep -v "information_schema" |grep -v "test"`
for db_name in $DBS
do
mkdir -p $BACKUPDIR/$DATE/$db_name
tables=`mysql -u$MYUSER -p$MYPASS -Bse "use $db_name;show tables"`
for table_name in $tables
do
mysqldump -u$MYUSER -p$MYPASS -h$HOST --single-transaction --master-data=2 $db_name $table_name >$BACKUPDIR/$DATE/$db_name/$table_name.sql
done
done
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。