MySQL中Innobackupex怎么用
这篇文章主要介绍MySQL中Innobackupex怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
成都创新互联主营蓟州网站建设的网络公司,主营网站建设方案,app软件开发公司,蓟州h5成都小程序开发搭建,蓟州网站营销推广欢迎蓟州等地区企业咨询
该脚本为Innobackupex全备脚本
Xtrabackup版本:2.4.3
#/bin/bash
#set variables
conf=/XXX/my.cnf #my.cnf的路径
user=
password=
socket=
backupdir=
name=fullback_`date +"%Y%m%d-%H:%M:%S"`
innobackupexlog=${backupdir}/log/innobackupexlog_`date +"%Y%m%d-%H:%M:%S"`
expire=7 #备份的数据保留的时间
#begin full backup
innobackupex --defaults-file=${conf} \
--user=${user} \
--password=${password} \
--socket=${socket} \
--slave-info \
--no-timestamp ${backupdir}/${name}&>>${innobackupexlog}
backupflag1=`tail -n 10 ${innobackupexlog} | grep "completed OK" | grep -v prints | wc -l`
if [ ${backupflag1} -eq 0 ]
then
echo "==============================================================="
echo "`date +"%Y-%m-%d %H:%M:%S"` backup failed!">> ${innobackupexlog}
echo "==============================================================="
exit 1
elif [ ${backupflag1} -eq 1 ]
then
echo "============================================================" >> ${innobackupexlog}
echo "backup success" >>${innobackupexlog}
echo "============================================================" >> ${innobackupexlog}
#begin recover redolog
echo "============================================================" >> ${innobackupexlog}
echo "`date +"%Y%m%d-%H:%M:%S"` Begin to Recover ..." >> ${innobackupexlog}
echo "============================================================" >> ${innobackupexlog}
innobackupex --defaults-file=${conf} --apply-log ${backupdir}/${name} &>>${innobackupexlog}
backupflag2=`tail -n 10 ${innobackupexlog} | grep "completed OK" | grep -v prints | wc -l`
if [ ${backupflag2} -gt 0 ]
then
echo "===============================================================" >>${innobackupexlog}
echo "`date +"%Y%m%d-%H:%M:%S"` Recover is success!" >>${innobackupexlog}
echo "===============================================================" >>${innobackupexlog}
else
echo "===============================================================" >>${innobackupexlog}
echo "Recover is failed!" >>${innobackupexlog}
echo "===============================================================" >>${innobackupexlog}
exit 1
fi
fi
#clean expired backup
find ${backupdir} -type d -name "fullback*" -mtime +${expire} | xargs /bin/rm -rf
find ${backupdir}/log -type f -name "innobackupexlog*" -mtime +${expire} | xargs /bin/rm -rf
以上是“MySQL中Innobackupex怎么用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
网站题目:MySQL中Innobackupex怎么用
分享URL:http://scyanting.com/article/ppdjgs.html