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,dump,备份脚本)