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

MySQL备份脚本

时间:2016-03-18 18:07:11      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:mysql   dump   备份脚本   

#!/bin/sh

################################################

#this scripts is created by tangbo

#tangbo QQ:79313760

################################################

#parameter defined  start 

BAKDATE=`date +%F`

MYUSER=root

MYPASS="111111"

MYSOCK=/data/3306/mysql.sock

DBNAME="caiwu"

MAIN_PATH=/server/backup

DATA_PATH=/server/backup

LOG_FILE=${DATA_PATH}/mysql_logs_${BAKDATE}.log

DATA_FILE=${DATA_PATH}/mysql_backup_${BAKDATE}.sql.gz


#command defined

MYSQL_PATH=/usr/local/mysql/bin

#MYSQL_DUMP="$MYSQL_PATH/mysqldump -u$MYUSER -p$MYPASS -S $MYSOCK -A  -B -F --single-transaction -e"

MYSQL_DUMP="$MYSQL_PATH/mysqldump -u$MYUSER -p$MYPASS -S $MYSOCK -F -B $DBNAME --default-character-set=gbk --single-transaction -e"

#backup command

${MYSQL_DUMP} | gzip > $DATA_FILE

#check backup result

du -sh $DATA_FILE >$LOG_FILE

mail -s "${BAKDATE} mysql bak log" 79313760@qq.com < $LOG_FILE

##################end##########################


本文出自 “山猫” 博客,谢绝转载!

MySQL备份脚本

标签:mysql   dump   备份脚本   

原文地址:http://cqtangbo.blog.51cto.com/2978612/1752566

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