您好,登錄后才能下訂單哦!
這篇文章主要介紹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怎么用”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。