本文共 473 字,大约阅读时间需要 1 分钟。
#! /bin/bash
DBPATH=/server/backupMYUSER=rootMYPASS=rootMYCMD="mysql -u$MYUSER -p$MYPASS"MYDUMP="mysqldump -u$MYUSER -p$MYPASS"[ -d "$DBPATH" ] && mkdir $DBPATHfor dbname in$MYCMD -e "show databases;"| sed '1,2d'|egrep -v "mysql|schema"
;domkdir $DBPATH/${dbname}$(date +%F) -pfor table in $MYCMD -e "show tables from $dbname"
;do$MYDUMP $dbname $table|gzip >$DBPATH/$(dbname)$(date +%F)/${dbname}_${table}.sql.gzdonedone 转载于:https://blog.51cto.com/546136/2067577