mysql 单表批量备份sh文件

#!/bin/bash
DBS=$(mysql -u root -padmin -e 'use database; show tables;' | awk '{ print $1 }');
for table in ${DBS}
do
dbbak="/home/db/backups/db-"${table}".sql";
dbbakgz=$dbbak".part.gz";
if [ -n "$(echo ${table:0-1}| sed -n "/^[a-z]\+$/p")" ];then
mysqldump -u root -padmin database ${table} > $dbbak;
gzip $dbbak;
fi
done

posted @ 2016-06-23 20:15  乡村猫  阅读(262)  评论(0编辑  收藏  举报