首页 > 代码库 > mysql 数据备份脚本
mysql 数据备份脚本
架构:
slave:
#!/bin/bash # DATATIME=`date -d "yesterday" +%F` BACKTIME=`date +"%Y-%m-%d %H:%M:%S"` BACKUP_DIR=‘/data/dbback‘ MYSQL_USER=‘root‘ MYSQL_PASSWORD=‘123456‘ DBNAME=‘fa‘ FTP_HOST=‘192.168.0.20‘ FTP_USER=backer FTP_USERPASS=backer FTP_PORT=10011 [ ! -d $BACKUP_DIR/$DATATIME ] && mkdir $BACKUP_DIR/$DATATIME mysqldump -u $MYSQL_USER -p${MYSQL_PASSWORD} --master-data=http://www.mamicode.com/2 --lock-all-tables --flush-logs --default-character-set=utf8 -R $DBNAME | gzip -9 >$BACKUP_DIR/$DATATIME/$DBNAME${DATATIME}_full.sql.gz 2> /tmp/back_error.txt"$BACKTIME Mysql slave ${DBNAME}_full error!" >> /tmp/back_error.txt mail -s "$DBNAME full back error !!" zhenglm@163.com < /tmp/back_error.txt else cd $BACKUP_DIR/$DATATIME/ md5sum $DBNAME${DATATIME}_full.sql.gz > $DBNAME${DATATIME}_full.md5.txt echo "$BACKTIME back Mysql slave ${DBNAME}_full ok " >/tmp/back_log.txt mail -s "Mysql data back ok !!" zhenglm@163.com < /tmp/back_log.txt fi find $BACKUP_DIR/ -type d -mtime +32 -exec rm -rf {} \; >/dev/null 2>&1 lftp -p $FTP_PORT $FTP_HOST -u $FTP_USER,$FTP_USERPASS <<EOF mkdir $DATATIME cd $DATATIME put $BACKUP_DIR/$DATATIME/$DBNAME${DATATIME}_full.sql.gz put $BACKUP_DIR/$DATATIME/$DBNAME${DATATIME}_full.md5.txt exit EOF exit 0
本文出自 “技术小菜” 博客,请务必保留此出处http://390892467.blog.51cto.com/2006821/1573919
mysql 数据备份脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。