#!/bin/bash
#name: mysqlbak.sh
bakdata="/opt/backup"
bakdate=`date +%Y-%m-%d_%H%M`
for i in `/usr/bin/mysql -uroot -p123456 -e "show databases;" | grep mysql_s*`
do
if [ ! -d "/opt/backup/$i" ]
then
mkdir /opt/backup/$i
fi
/usr/bin/mysqldump -uroot -p123456 --database $i | gzip > $bakdata/$i/"$i"_"$bakdate".sql.gz
done
阅读(589) | 评论(0) | 转发(0) |