MySQL分表备份shell脚本

#!/bin/sh

BACKPATH=/server/backup

MYPASS=ruanganlove999

SOCKET=/data/3306/mysql.sock

MYCMD="mysql -u$MYUSER -P$MYPASS -S $SOCKET"

MYDUMP="mysqldump -u$MYUSER -p$MYPASS -S$SOCKET -x-B -F -R"

[ ! -d $BACKPATH ] && mkdir -p $BACKPATH

DBLIST=`$MYCMD -e "show databases;"|sed 1d|egrep -v "_schema|mysql"`

for dbname in $DBLIST

do

        $MYDUMP$dbname|gzip >/server/backup/${dbname}_$(date +%F).sql.gz

done

 

 

======================================

简单脚本:

cat fenku.sh

for dbname in `mysql -uroot -pruanganlove999 -e"show databases;"|grep -Evi "database|infor|perfor"`

do

        mysqldump-uroot -pruanganlove999 --events -B$dbname|gzip>/opt/bak/${dbname}_bak.sql.gz

done

 

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS