Xtrabackup MySQL8.0 the backup tool

With the introduction of MySQL 8.0, Percona company also launched a percona-xtrabackup-8.0, while the original 2.4 version also will continue to support MySQL and Percona Server 5.6 and 5.7 databases.

Because MySQL 8.0 in the data dictionary, redo logs and undo the change log is not compatible with previous versions introduced, so Percona XtraBackup 8.0 is not currently supported versions prior to 8.0.

Unlike using an older version of the original xtrabackup8.0 major record under this article.

Usage: [xtrabackup [--defaults-file=#] --backup | xtrabackup [--defaults-file=#] --prepare] [OPTIONS]

dir---target   Where do you want the target directory directory backup. If the directory does not exist, xtrabackup will create it. If the directory does exist and is empty, xtrabackup will succeed ; xtrabackup does not overwrite existing files; will be at the operating system level error, the file exists.

--backup            take backup to target-dir 

--prepare            PREPARE A Starting mysql Backup for Server Backup to start at The ON mysql server on a backup backup ready. (Similar innobackupex --apply-log)

--apply-log-only    this is more important. The main application and increase equipment, in regular backups, perform two operations in order to make the database consistent: from the log files replay the transaction has been submitted to the data file, rollback uncommitted transactions. In preparation for backup, you must skip the rollback of uncommitted transactions because the transaction when the backup uncommitted may be in progress, they are likely to be submitted in the next incremental backup. You should use -apply-log-only option to prevent the rollback phase.

Warning: If you do not use -apply-log-only option to prevent the rollback phase, your incremental backup will be useless. After the transaction is rolled back, it can not be applied to further incremental backup.

--compress  This option tells xtrabackup using the specified compression algorithm outputs all data, including transaction log files and metadata files. Currently the only supported algorithm is quicklz. And --compress-threads used in conjunction.

--compact create a compact backup by skipping the secondary index page.

--compress-threads   This option specifies the number of worker threads in parallel xtrabackup for data compression. This option defaults to 1. Parallel compression (compression thread) can be copied and parallel file (parallel) used together. For example, - parallel = 4 --compress --compress- threads = 2 will create four I / O thread, and transfers the read data to the two compression threads.

--copy-back  copy all the files in the backup directory prior to its original position. Unless you specify a non-empty directory mandatory option, otherwise this option does not copy an existing file. And MariaDB one of Mariabackup similar copy-back, do it to ensure datadir directory is empty, you can change the original directory name, then create a new directory.

--databases list of database tables and specify this option should be backed up, it supports database_name.table_name, for example, you want to back up test su table in the library, - databases = test.su.

--databases-exclude to exclude the name of the database based on the same basic syntax --databases, you do not want to back up a database or table. be careful! This option takes precedence over the --databases.

--galera-info  This option creates xtrabackup_galera_info file that contains the local node when the backup. Option should be used when performing Percona XtraDB cluster backup.

--incremental  This option tells xtrabackup create an incremental backup. Xtrabackup it is passed to the child process. After you specify this option, you can also specify --incremental-lsn or --incremental-basedir. If both options are not provided, then by default option - incremental-basedir passed to xtrabackup, set the backup base directory first timestamp backup directory. With the original old version --incremental similar

--slave-info  This option is useful when backing up replicated slave servers. It prints the primary server binary log position. It also changes this information as the main command writes xtrabackup_slave_info file. From the server, binary log the location of the command file saved in xtrabackup_slave_info by starting a backup on this issue and a CHANGE master server from the command to set the new master server.

Full backup:

xtrabackup --defaults-file=/etc/my.cnf  --user='xx' --password='xx' -S /tmp/mysql.sock --compress --compress-threads=2 --backup --target-dir=/opt/mydump/

Percona compression mode need to install self-development qpress compression tool.

yum install  https://repo.percona.com/yum/percona-release-latest.noarch.rpm  
yum install qpress -y

 

You can look at the contents of the backup out, as shown below:

 

.Qp are based on the ending, unreadable, it can be considered another encrypted.

Decompression

 for bf in `find . -iname "*\.qp"`; do qpress -d $bf $(dirname $bf) && rm -f $bf; done

 

 

Recover incremental data (this step is similar innobackupex --apply-log) during backup

xtrabackup  --prepare --target-dir=/opt/mydump/

 

restore

 

① close the mysqld process

 

② ensure datadir directory is empty, you can put the original data directory mv elsewhere

 

③ recovery

# xtrabackup --defaults-file=/etc/my.cnf --copy-back --target-dir=/opt/mydump/

 

④ Change the directory properties

chown mysql:mysql -R /data/mysql

 

⑤ start mysqld process

Increased equipment (first create a full backup):

xtrabackup --backup --target-dir=/opt/mydump

 

Based on this and then do a full backup by backup:

xtrabackup --backup --target-dir=/opt/incr1 --incremental-basedir=/opt/mydump

 

The second apparatus by:

xtrabackup --backup --target-dir=/opt/incr2  --incremental-basedir=/opt/incr1

Application of a preparation to increase all equipment:

xtrabackup --prepare --apply-log-only --target-dir=/opt/mydump --incremental-dir=/opt/incr1

The second application equipment increased to a full backup (this time would not add --apply-log-only, as to prepare for the same reasons by the old version):

xtrabackup --prepare --target-dir=/opt/mydump --incremental-dir=/opt/incr2

Full recovery process and prepare the same.

 

 

https://www.linuxidc.com/Linux/2016-08/134535.htm

https://www.percona.com/doc/percona-xtrabackup/2.4/howtos/recipes_ibkx_compressed.html

 

Guess you like

Origin www.cnblogs.com/guoweilf/p/12053173.html