#!/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
时间: 2024-10-03 23:53:41