#!/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
原文链接:https://www.f2er.com/centos/374726.html