開始增量備份:
[[email protected] ~]# xtrabackup --backup --user=root --password=123 --target-dir=/data/backups/inc1 \> --incremental-basedir=/data/backups查看增量目錄下的LSN號碼對比全量目錄下的LSN號碼
[[email protected] ~]# cat /data/backups/inc1/xtrabackup_checkpoints backup_type = incrementalfrom_lsn = 2628274to_lsn = 2633017last_lsn = 2633026compact = 0recover_binlog_info = 0[[email protected] ~]# 此時增量備份也已經(jīng)完成.接下來我們進行數(shù)據(jù)恢復(fù)
首先對全備備份目錄操作:
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/然后應(yīng)用增量日志
xtrabackup --prepare --apply-log-only --target-dir=/data/backups --incremental-dir=/data/backups/inc1這里注意.如果增量不止一個的話.后邊的增量和全備合并的時候不需要加--apply-log-only停止現(xiàn)在的數(shù)據(jù)庫并把數(shù)據(jù)目錄清除:
pkill mysqldrm -rf /data/3306/data/*將全備目錄下的文件復(fù)制到數(shù)據(jù)目錄:
xtrabackup --copy-back --target-dir=/data/backups/修改權(quán)限chown -R mysql:mysql /data/ 啟動mysql/etc/init.d/mysqld start連接進入數(shù)據(jù)庫查看數(shù)據(jù)是否恢復(fù)
mysql> show databases;+--------------------+| Database|+--------------------+| information_schema || inc1|| increment|| mysql|| performance_schema || sys|+--------------------+6 rows in set (0.00 sec)mysql> use increment;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+---------------------+| Tables_in_increment |+---------------------+| increment|+---------------------+1 row in set (0.00 sec)mysql> select * from increment;+------+------+| id| name |+------+------+|1 | lzm|+------+------+1 row in set (0.00 sec)可以看到我們的增量數(shù)據(jù)也已經(jīng)恢復(fù)了
關(guān)于8017之后加入的clone plguin的備份方式請查看我之前的文章MySQL 8.0新特性之clone plugin
四 總結(jié):這篇文章為大家分享了MySQL的邏輯備份及物理備份方式.以及詳細的使用方法!
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請您及時就醫(yī)或請專業(yè)人士給予相關(guān)指導(dǎo)!
「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助:- icloud備份恢復(fù)到新手機方法 icloud數(shù)據(jù)恢復(fù)到新手機
- mysql創(chuàng)建數(shù)據(jù)庫步驟 java鏈接mysql數(shù)據(jù)庫的詳細步驟
- mysql和oracle的區(qū)別分析 oracle和mysql的優(yōu)缺點對比
- sql數(shù)據(jù)庫使用教程 sql查看表字段類型
- mysql安裝教程分享 mysql的安裝包在哪個文件
- php查詢數(shù)據(jù)庫并輸出實例講解 php查詢數(shù)據(jù)庫并輸出實例
- redis數(shù)據(jù)恢復(fù)原理講解 redis備份和恢復(fù)原理
- 數(shù)據(jù)庫性能優(yōu)化方法 oracle性能調(diào)優(yōu)總結(jié)
- oracle數(shù)據(jù)庫常用命令 mysql數(shù)據(jù)遷移到oracle
- oppo手機解除密碼方法 oppo手機怎么備份所有數(shù)據(jù)
