首页 > 代码库 > xtrabackup备份脚本
xtrabackup备份脚本
背景:现网环境全备份脚本:基于xtrabackup命令
#!/bin/sh # MySQL端口 PORT=‘3003‘ # 备份用户 USER=‘bkpuser‘ PAWD=‘bkpuser‘ Time=`date +%Y%m%d_%H%M%S` # 备份路径 BASEDIR=‘/data/backup‘ # 备份保留天数 BACKUP_SAVE_DAYS=‘2‘ # 备份过程->LOG文件 LOGFILE="${BASEDIR}/${Time}info.log" touch ${LOGFILE} # 开始备份 StartTime=`date +%Y%m%d_%H%M%S` echo "Start-Time :${StartTime}" |tee -a ${LOGFILE} echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" |tee -a ${LOGFILE} # 备份命令 innobackupex --defaults-file=/data/config/my${PORT}.cnf --user=${USER} --password=${PAWD} --stream=tar /data/backup/ 2>> ${LOGFILE}|gzip >/data/backup/${Time}.tar.gz # 结束备份 StopTime=`date +%Y%m%d_%H%M%S` echo "Stop-Time :${StopTime}" |tee -a ${LOGFILE} echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" |tee -a ${LOGFILE} # 清除N天之前的备份 cd ${BASEDIR} /usr/bin/find -name "*.tar.gz" -mtime +${BACKUP_SAVE_DAYS} -exec rm {} \; /usr/bin/find -name "*info.log" -mtime +${BACKUP_SAVE_DAYS} -exec rm {} \;
xtrabackup备份脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。