Percona-xtrabackup Backup

Source: Internet
Author: User
Tags percona

Software version:

percona-xtrabackup-2.2.10

mysql-5.6.23

    1. Xtrabackup Installation

2. full standby and recovery

(1) fully prepared

View Database


[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456/bak/mysql/

This statement copies the data file ( specified by the variable datadir in my.cnf ) to the backup directory (/bak/mysql/), note: If you do not specify -- Defaults-file, the default value is /etc/my.cnf.

after the backup is successful, a timestamp directory is created under the backup directory (the directory created in this example is /bak/mysql/2015-07-08_18-52-43), where the backup file is stored.


(2) Recovery

Delete Database test123, try to recover


Before recovering, close the database and delete the data files and log files.



[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--apply-log/bak/mysql/ 2015-07-08_18-52-43/

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--copy-back/bak/mysql/ 2015-07-08_18-52-43/

Recovery is divided into two steps:

Step 1 is apply-log, in order to speed up, it is generally recommended to set --use-memory, after this step is completed, the directory /bak/mysql/2015-07-08_ the backup file under 18-52-43/is ready.

Step 2 is copy-back, which copies the backup files to the original data directory. When the recovery is complete, be sure to check the data Catalog for the correct owner and permissions.



3. incremental backup and recovery

Note:Innobackupex Incremental backups are only for InnoDB such a support transaction engine, and for engines such as MyISAM, they are still fully-prepared.

(1) Incremental backup

incremental backups need to be based on full provisioning, we already have a full standby (/bak/mysql/2015-07-08_18-52-43/), and we need to do incremental backups on this fully-prepared basis.

Test the new library, import new data, and make incremental backups.



[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--incremental-basedir=/ bak/mysql/2015-07-08_18-52-43/--incremental/bak/mysql/


where --incremental-basedir points to the fully-prepared directory,--incremental The directory that points to the incremental backup.

after the execution of the above statement succeeds, a timestamp subdirectory is created in the directory executed by--incremental (in this case:/bak/mysql/2015-07-08_19-46-30), All files with incremental backups are stored in this directory.

in the backup directory, there is a file xtrabackup_checkpoints records The backup information, the full information is as follows:


Information based on this fully-prepared incremental backup is as follows:


as can be seen from the above, the FROM_LSN of an incremental backup is exactly equal to the fully prepared TO_LSN.

So, can we do incremental backups on the basis of incremental backups? The answer is yes, just take the--incremental-basedir to perform the last incremental backup of the directory, as follows:

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--incremental-basedir=/ bak/mysql/2015-07-08_19-46-30/--incremental/bak/mysql/


its xtrabackup_checkpoints records the backup information as follows:


As you can see, the FROM_LSN of this incremental backup starts with the to_lsn of the last incremental backup .

(2) Recovery

Delete Database test456, try to recover


Before recovering, close the database and delete the data files and log files.



The recovery of an incremental backup is much more complex than full provisioning, and the first step is to redo the committed log under all backup directories, such as:

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--apply-log--redo-only/ bak/mysql/2015-07-08_18-52-43/

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--apply-log--redo-only/ bak/mysql/2015-07-08_18-52-43/--incremental-dir=/bak/mysql/2015-07-08_19-46-30/

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--apply-log--redo-only/ bak/mysql/2015-07-08_18-52-43/--incremental-dir=/bak/mysql/2015-07-08_21-01-19/

where /bak/mysql/2015-07-08_18-52-43/ refers to a fully-prepared directory,/bak/mysql/2015-07-08_19-46-30/ is the first incremental backup,/ bak/mysql/2015-07-08_21-01-19/ refers to the second incremental backup, and so on.

After the execution of the above statement succeeds, the final data is in the fully-prepared directory.

When the first step is complete, we begin the second step: Roll back the unfinished log:

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--apply-log/bak/mysql/ 2015-07-08_18-52-43/

after the above execution, the backup file in/bak/mysql/2015-07-08_18-52-43/is fully ready and the final step is to copy:

[Email protected]]# innobackupex--defaults-file=/etc/my.cnf--user=root--password=123456--copy-back/bak/mysql/ 2015-07-08_18-52-43/

Modify directory permissions to start MySQL.


Modify directory permissions to start MySQL.

Recovery complete, such as


(written by Xiao Cui)

This article is from the "believe it or not you" blog, please be sure to keep this source http://312461613.blog.51cto.com/965442/1673846

Percona-xtrabackup Backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.