Mysql中xtrabackup備份的實(shí)現(xiàn)
更新時(shí)間:2023年12月12日 09:22:28 作者:一個(gè)小宏混
Xtrabackup是Percona團(tuán)隊(duì)開發(fā)的用于MySQL數(shù)據(jù)庫物理熱備份的開源備份工具,本文就來介紹一下Mysql中xtrabackup備份的實(shí)現(xiàn),就有一定的參考價(jià)值,感興趣的可以了解一下
1.準(zhǔn)備環(huán)境
安裝數(shù)據(jù)庫
[root@localhost ~]# yum-y install mysql mysql-server [root@localhost ~]# systemctl start mysqld [root@localhost ~]# grep pass /var/log/mysql.log [root@localhost ~]# mysqladmin -uroot -p'old-passwd' password "new-passwd"
email配置
[root@localhost ~]# yum -y install mailx [root@localhost ~]# vi /etc/mail.rc #將下面信息填入到文件中 set from=********@qq.com set smtp=smtp.qq.com set smtp-auth-user=**********@qq.com set smtp-auth-password=************ #第三方登錄碼 set smtp-auth=login
2.腳本解析
#!/bin/bash #校驗(yàn)時(shí)間 ntpdate ntp.aliyun.com >> /dev/null #檢查是否創(chuàng)建目錄 find /xtrabackup/ -name '*' >> /dev/null if [[ $? -ne 0 ]];then mkdir /xtrabackup/ fi find /xtrabackup/log/ -name '*' >> /dev/null if [[ $? -ne 0 ]];then mkdir -p /xtrabackup/log fi #定義變量 User=root Password=QianFeng@123 Email_num=2756375538@qq.com #完全備份 backup_full(){ innobackupex --user=$User --password=$Password /xtrabackup/ >> /xtrabackup/log/backup.log 2>&1 } #增量備份 backup_incremental(){ #獲取前一天時(shí)間 before=$(date -d "yesterday" +%Y-%m-%d_%H) Before_path=`find /xtrabackup/ -name "${before}*"` innobackupex --user=$User --password=$Password --incremental /xtrabackup/ --incremental-basedir=$Before_path >> /xtrabackup/log/backup.log 2>&1 } #差異備份 backup_differential(){ date_times=$(date +%u) if [[ $date_times -eq 4 ]];then before_3_days=$(date -d "3 days ago" +%Y-%m-%d_%H) Full_path=`find /xtrabackup/ -name "${before_3_days}*"` innobackupex --user=$User --password=$Password --incremental /xtrabackup --incremental-basedir=$Full_path >> /xtrabackup/log/backup.log 2>&1 else before_6_days=$(date -d "6 days ago" +%Y-%m-%d_%H) Full_path=`find /xtrabackup/ -name "${before_3_days}*"` innobackupex --user=$User --password=$Password --incremental /xtrabackup --incremental-basedir=$Full_path >> /xtrabackup/log/backup.log 2>&1 fi } #定義郵件 email_worker(){ echo "數(shù)據(jù)備份失敗" | mail -s "數(shù)據(jù)庫備份失敗" $Email_num } #主函數(shù) date_time=$(date +%u) case $date_time in 1) backup_full ;; 2|3|5|6) backup_incremental ;; 4|7) backup_differential ;; esac if [[ $? -ne 0 ]];then email_worker fi
到此這篇關(guān)于Mysql中xtrabackup備份的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Mysql xtrabackup備份內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- 使用xtrabackup實(shí)現(xiàn)mysql備份
- MySQL使用xtrabackup進(jìn)行備份還原操作
- xtrabackup備份還原MySQL數(shù)據(jù)庫
- MySQL使用Xtrabackup備份流程詳解
- 詳解如何利用Xtrabackup進(jìn)行mysql增量備份
- MySQL xtrabackup 物理備份原理解析
- MySQL之xtrabackup備份恢復(fù)的實(shí)現(xiàn)
- MySQL數(shù)據(jù)xtrabackup物理備份的方式
- mysql使用物理備份安裝xtrabackup的詳細(xì)過程
- mysql中xtrabackup全量備份/增量備份及恢復(fù)
相關(guān)文章
mysql 主從復(fù)制如何跳過報(bào)錯(cuò)
這篇文章主要介紹了mysql 主從復(fù)制如何跳過報(bào)錯(cuò),幫助大家更好的理解和使用MySQL 數(shù)據(jù)庫,感興趣的朋友可以了解下2020-10-10Windows環(huán)境下MySQL 8.0 的安裝、配置與卸載
這篇文章主要介紹了Windows環(huán)境下MySQL 8.0 的安裝、配置與卸載步驟,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09mysql 修改密碼和設(shè)置允許遠(yuǎn)程登錄
這篇文章主要介紹了mysql 修改密碼和設(shè)置允許遠(yuǎn)程登錄的相關(guān)資料,需要的朋友可以參考下2015-07-07mysql提示Changed limits: max_open_files: 2048 max_connections:
這篇文章主要介紹了mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64的解決,需要的朋友可以參考下2014-05-05mysql 無限級(jí)分類實(shí)現(xiàn)思路
關(guān)于該問題,暫時(shí)自己還沒有深入研究,在網(wǎng)上找到幾種解決方案,各有優(yōu)缺點(diǎn)。2011-08-08