#!/bin/bash
mkdir /backup
cd /backup
dateDIR=`date +"%y-%m-%d"`
mkdir -p $dateDIR/data
for i in `mysql -uroot -p123456 -e "show databases" | grep -v "Database"`
do
mysqldump -uroot -p123456 --default-character-set=gbk --opt $i | gzip > /backup/$dateDIR/data/${i}_${dateDIR}.sql.gz
done
binlog_rm=`tail -n 1 $path/mysql-bin.index | sed 's/.\///'`
mysql -uroot -p123456 -e "purge binary logs to '$binlog_rm'"
阅读(822) | 评论(0) | 转发(0) |