时间:2021-07-01 10:21:17 帮助过:65人阅读
#!/bin/sh
USER=root
PASSWD=oldboy
SOCKET=/data/3306/mysql.sock
LOGIN="mysql -u$USER -p$PASSWD -S $SOCKET"
DATABASE=$($LOGIN -e "show databases;"|egrep -v "*chema|mysql"|sed ‘1d‘)
DUMP="mysqldump -u$USER -p$PASSWD -S $SOCKET"
for database in $DATABASE
do
TABLE=$($LOGIN -e "use $database;show tables;"|sed ‘1d‘)
for table in $TABLE
do
[ -d /server/backup/$database ] || mkdir -p /server/backup/$database
# [ ! -d /server/backup/$database ] && mkdir -p /server/backup/$database
$DUMP $database $table |gzip >/server/backup/$database/${database}_${table}_$(date +%F).sql.gz
done
done
=============================================================
16、MySQL数据库分库分表备份脚本
标签:mysql数据库分库分表备份脚本