1.查看mysql上都有哪些库
*************************** 1. row ***************************
Database: information_schema
*************************** 2. row ***************************
*************************** 3. row ***************************
export back_dir=/data/bak
export mysql_dir=/usr/local/mysql-5.1.56
for i in $(mysql -uroot -p$pass -e 'show databases \G' | grep Database | cut -d: -f2)
$mysql_dir/bin/mysqldump --opt $i -p$pass --skip-lock-tables>$back_dir/$i.$(date +%Y%m%d).sql
#use fetion to notice dba
LD_LIBRARY_PATH=/usr/lib /usr/local/fetion/fetion --mobile=159xxxx3240 --pwd=123456 --to=159xxxx3240 --msg-utf8=mysql backup is success !
0 3 * * * sh /usr/bin/back.sh
本文转自 baiying 51CTO博客,原文链接:http://blog.51cto.com/baiying/608122,如需转载请自行联系原作者