#!/bin/bash
#mysql backup admin
cd /root/backup
dateDir=`date +"%y-%m-%d"`
dateDir2=`date -d '-2 day' +%y-%m-%d`
mkdir -p $dateDIR/data
for i in `/usr/bin/mysql -uroot -pabc123? -e "show databases"|grep -v "Database"|grep -v "information_schema"`
do
/usr/bin/mysqldump -uroot -pabc123? $i|gzip >/root/backup/${i}_${dateDir}.gz
rm -rf /root/backup/${i}_${dateDir2}.gz
done
本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/1135660