MySQL备份脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL备份脚本相关的知识,希望对你有一定的参考价值。
#!/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" [email protected] < $LOG_FILE
##################end##########################
本文出自 “山猫” 博客,谢绝转载!
以上是关于MySQL备份脚本的主要内容,如果未能解决你的问题,请参考以下文章