xtrabackup备份脚本
Posted 缥缈之旅
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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备份脚本的主要内容,如果未能解决你的问题,请参考以下文章