mysql-xtrabackup backup and recovery

1, xtrabackup installation

Version 8.0 - Support mysql8

wget https://www.percona.com/downloads/Percona-XtraBackup-LATEST/Percona-XtraBackup-8.0-7/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm

2.4 version supports mysql5.7

https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.15/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.15-1.el7.x86_64. rpm
after download or upload centos system

yum install -y percona-xtrabackup-24-2.4.15-1.el7.x86_64.rpm
rpm -qa |grep xtrabackup
which xtrabackup

Common options:
--host specified host
--user Specifies the user name
--password specify the password
--port port specify
--databases specified database
--incremental create an incremental backup
--incremental-basedir specified directory contains a full backup of
--incremental -dir specifies the directory containing incremental backups
--apply-log backup preprocessing operation
under normal circumstances, after the completion of the backup, restore operation of data can not be used yet, because the backup data may be included in the transaction or not submitted It has been submitted but not yet synchronized to the data file transactions. Therefore, at this time the data file is still processed in an inconsistent state. The main role of "ready" it is through transaction rollback uncommitted transaction synchronization and data files that have been submitted to also make the data files in a consistent state.
--redo-only does not roll back the uncommitted transactions
--copy-back recovery backup directory
Note: the need to start backup MySQL, MySQL must be turned off when restoring, clear the mysql data directory and can not be re-initialized, the data should be carried out immediately after the resumption of a full backup

2, xtrabackup full backup and recovery

Backup:

innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 /path/

Stop the service, delete the directory data

service mysqld stop
cd /data/mysqldata/  
rm -rf *

restore:

innobackupex --apply-log /path/2018-07-30_11-04-55/    #保持一致性
innobackupex --defaults-file=/etc/my.cnf --copy-back /path/2018-07-30_11-04-55/
chown -R mysql.mysql /data/mysqldata/
service mysqld start

3, xtrabackup incremental backup and recovery

innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 --incremental /path2/ --incremental-basedir=/path/2017-12-04_13-57-29

directory --incremental / path2 / incremental backup files specified backup
directory on the specified equipment --incremental-basedir a full or incremental backup
incremental recovery

innobackupex --apply-log --redo-only /path/2017-12-04_13-57-29/
innobackupex --apply-log --redo-only /path/2017-12-04_13-57-29/ --incremental-dir=/path2/2017-12-05_09-27-06/
innobackupex --defaults-file=/etc/my.cnf --copy-back /path/2017-12-04_13-57-29/

4, commonly used commands

cat xtrabackup_checkpoints # view the backup checkpoint

Guess you like

Origin www.cnblogs.com/kylingx/p/11714958.html