码迷,mamicode.com
首页 > 数据库 > 详细

Mysql数据备份

时间:2014-11-25 20:12:57      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   color   sp   数据   div   2014   art   

 1 #!/bin/bash
 2 #2014-11-4
 3 #author pdd
 4 #backup mysql
 5 
 6 backup_target_dir="/data/mysql_backup"
 7 backup_logs_dir="/data/mysql_backup/logs"
 8 
 9 Date=$(date "+%Y.%m.%d")
10 LDate=$(date "-d -4 day" "+%Y.%m.%d") # keep 5 backup files
11 
12 echo "----------$(date "+%F %T")----------" >>$backup_logs_dir/mysql.log
13 echo "backup start" >> $backup_logs_dir/mysql.log
14 
15 mysqldump -uroot -pkobe5824 --all-databases >$backup_target_dir/mysql_$Date.sql 2>/dev/null
16 
17 if [ 0 -eq $? ];then
18     echo "mysql backup success !" >>$backup_logs_dir/mysql.log
19 else
20     echo "mysql backup fail " | tee -a $backup_logs_dir/mysql.log | mail -s mysql 254995740@qq.com
21 fi
22 
23 if [ -e $backup_target_dir/mysql$LDate.sql ];then
24     echo "rm success !" >> $backup_logs_dir/mysql.log
25 else
26     echo -e "rm fail\n" | tee -a $backup_logs_dir/mysql.log | mail -s rm 254995740@qq.com
27 fi

 

Mysql数据备份

标签:style   blog   ar   color   sp   数据   div   2014   art   

原文地址:http://www.cnblogs.com/metasequoia/p/4121543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!