CentOS 6.8 x86_64bit shell实现mysql多实例分库备份
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.8 x86_64bit shell实现mysql多实例分库备份相关的知识,希望对你有一定的参考价值。
#!/bin/bash
MYUSER=root
MYPASS=123456
SOCKET=/data/3306/mysql.sock
MYCMD="mysql -u$MYUSER -p$MYPASS -S $SOCKET"
BAKPATH="/backup/$(date +%F)"
[ ! -d $BAKPATH ] && mkdir -p $BAKPATH
for dbname in `$MYCMD -e 'show databases;'|sed '1d'|grep -v "_schema"`
do
$MYDUMP -B -x --events $dbname|gzip >$BAKPATH/${dbname}.sql.gz
if [ $? -eq 0 ];then
echo "$dbname" >>$BAKPATH/${dbname}.log
fi
done
以上是关于CentOS 6.8 x86_64bit shell实现mysql多实例分库备份的主要内容,如果未能解决你的问题,请参考以下文章