mysql -uroot -phowhy@123 -e ‘show databases;‘ | grep -ivE ‘waring|database|mysql‘|sed -r "s#^(.*)#mysqldump -uroot -phowhy@123 --evens -B \1 |gzip > /opt/\1_$(date +%F).sql.gz#g" |bash
for db in `mysql -uroot -phowhy@123 -e ‘show databases;‘ | grep -ivE ‘waring|database|mysql‘`;
do
mysqldump -uroot -phowhy@123 --events -B $db | gzip > /opt/$db_$(date +%F).sql.gz
done
原文:http://www.cnblogs.com/howhy/p/6286146.html