欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • 淺談mysql數(shù)據(jù)庫中的using的用法

    淺談mysql數(shù)據(jù)庫中的using的用法

    在用Join進(jìn)行多表聯(lián)合查詢時(shí),我們通常使用On來建立兩個(gè)表的關(guān)系。其實(shí)還有一個(gè)更方便的關(guān)鍵字,那就是Using。
    2015-04-04
  • mysql 主從復(fù)制如何跳過報(bào)錯(cuò)

    mysql 主從復(fù)制如何跳過報(bào)錯(cuò)

    這篇文章主要介紹了mysql 主從復(fù)制如何跳過報(bào)錯(cuò),幫助大家更好的理解和使用MySQL 數(shù)據(jù)庫,感興趣的朋友可以了解下
    2020-10-10
  • Windows環(huán)境下MySQL 8.0 的安裝、配置與卸載

    Windows環(huán)境下MySQL 8.0 的安裝、配置與卸載

    這篇文章主要介紹了Windows環(huán)境下MySQL 8.0 的安裝、配置與卸載步驟,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-09-09
  • MySQL中查詢字段為空或者為null的方法

    MySQL中查詢字段為空或者為null的方法

    這篇文章主要介紹了MySQL中查詢字段為空或者為null的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • mysql 修改密碼和設(shè)置允許遠(yuǎn)程登錄

    mysql 修改密碼和設(shè)置允許遠(yuǎn)程登錄

    這篇文章主要介紹了mysql 修改密碼和設(shè)置允許遠(yuǎn)程登錄的相關(guān)資料,需要的朋友可以參考下
    2015-07-07
  • MySQL 服務(wù)和數(shù)據(jù)庫管理

    MySQL 服務(wù)和數(shù)據(jù)庫管理

    今天MySQL總結(jié)一些方法和一些基礎(chǔ)的內(nèi)容,下面文章將圍繞MySQL 服務(wù)與數(shù)據(jù)庫管理得相關(guān)資料展開內(nèi)容,需要的朋友可以參考一下,希望對(duì)你有所幫助
    2021-11-11
  • MySQL數(shù)據(jù)庫之事務(wù)簡析

    MySQL數(shù)據(jù)庫之事務(wù)簡析

    這篇文章主要介紹了MySQL數(shù)據(jù)庫之事務(wù)簡析,MySQL數(shù)據(jù)庫中的事務(wù)是一組數(shù)據(jù)庫操作,它們被視為一個(gè)整體,要么全部執(zhí)行成功,要么全部失敗回滾,MySQL支持四種事務(wù)隔離級(jí)別,其中默認(rèn)的事務(wù)隔離級(jí)別是REPEATABLE?READ,需要的朋友可以參考下
    2023-09-09
  • mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64的解決

    mysql提示Changed limits: max_open_files: 2048 max_connections:

    這篇文章主要介紹了mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64的解決,需要的朋友可以參考下
    2014-05-05
  • mysql 無限級(jí)分類實(shí)現(xiàn)思路

    mysql 無限級(jí)分類實(shí)現(xiàn)思路

    關(guān)于該問題,暫時(shí)自己還沒有深入研究,在網(wǎng)上找到幾種解決方案,各有優(yōu)缺點(diǎn)。
    2011-08-08
  • MySQL中的基本查詢語句學(xué)習(xí)筆記

    MySQL中的基本查詢語句學(xué)習(xí)筆記

    這篇文章主要介紹了MySQL中的基本查詢語句學(xué)習(xí)筆記,包括使用limit限制查詢結(jié)果條數(shù)和合并查詢結(jié)果的方法,需要的朋友可以參考下
    2016-03-03

最新評(píng)論