MySQL中Innobackupex怎么用-创新互联
这篇文章主要介绍MySQL中Innobackupex怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
专注于为中小企业提供网站设计、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业阜城免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。该脚本为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://azwzsj.com/article/eooic.html