首页 > 代码库 > Mysql数据备份
Mysql数据备份
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 files11 12 echo "----------$(date "+%F %T")----------" >>$backup_logs_dir/mysql.log13 echo "backup start" >> $backup_logs_dir/mysql.log14 15 mysqldump -uroot -pkobe5824 --all-databases >$backup_target_dir/mysql_$Date.sql 2>/dev/null16 17 if [ 0 -eq $? ];then18 echo "mysql backup success !" >>$backup_logs_dir/mysql.log19 else20 echo "mysql backup fail " | tee -a $backup_logs_dir/mysql.log | mail -s ‘mysql‘ 254995740@qq.com21 fi22 23 if [ -e $backup_target_dir/mysql$LDate.sql ];then24 echo "rm success !" >> $backup_logs_dir/mysql.log25 else26 echo -e "rm fail\n" | tee -a $backup_logs_dir/mysql.log | mail -s ‘rm‘ 254995740@qq.com27 fi
Mysql数据备份
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。