MySQL uses Innobackupex online backup scheme (full-volume + increment) operation record

Source: Internet
Author: User
Tags types of tables mysql backup perl script

In the daily operation of Linux, the backup of MySQL database is a very important part. With regard to MySQL backup and recovery, it is more traditional to use the Mysqldump tool. Today introduce another MySQL backup tool Innobackupex, use it to do full and incremental backup MySQL , only according to my actual operation to do a record, such as the wrong, please point out ~

First, the introduction of Innobackupex
Xtrabackup is an open source software developed by Percona, a scripting tool that is done in the Perl language, enables very fast backup and recovery of MySQL databases, and supports online hot backup (backup without affecting data read and write). This tool calls the Xtrabackup and TAR4IBD tools to implement many tasks and backup logic that are not performance-critical, and can be said to be an open source alternative to the InnoDB hot spare ibbackup.
The Xtrabackup contains two tools:
1) Xtrabackup: Tool for hot backup INNODB,XTRADB engine table, cannot back up other tables.
2) Innobackupex: perl script for the Xtrabackup package, provides the ability to use MyISAM (lock table) and InnoDB engine, and hybrid engine backup.
Innobackupex is more powerful than Xtarbackup, which integrates xtrabackup and other features, not only for full backup/restore, but also for time-based incremental backup and recovery.

What Xtrabackup can do
1) Online (hot) backup of the entire library InnoDB, XTRADB table
2) Incremental backup based on Xtrabackup backup (InnoDB only)
L3) generate backups as streams that can be saved directly to a remote machine (useful when the hard disk space is low)

the MySQL database itself provides tools that do not support true incremental backups, and binary log recovery is point-in-time (Point-in-time) recovery instead of incremental backups. The Xtrabackup tool supports incremental backups of the InnoDB storage engine, The working principle is as follows:
1) First complete a full backup and record the LSN (log Sequence number) of the checkpoint at this point.
2) in the process incremental backup, compares the LSN of each page in the tablespace to the LSN at the time of the last backup, and if so, backs up the page and logs the LSN of the current checkpoint.

Innobackupex how to back up MySQL data
Innobackupex first calls Xtrabackup to back up the InnoDB data file, Innobackupex views the file xtrabackup_suspended when Xtrabackup is finished, and then executes the FLUSH TABLES With READ LOCK "to back up other files

Innobackupex How to recover MySQL data
Innobackupex first read my.cnf, view variables (datadir,innodb_data_home_dir,innodb_data_file_path,innodb_log_group_home_dir) The corresponding directory is present, OK after the relevant directory exists, then copy the MyISAM table and index, and then copy innodb tables, indexes, and logs.

--------------------------------------------------------------------------------------------------------------- ---------------------------
The above briefly summarizes the principles of Innobackupex backup and recovery, and the following details how it works for backup and recovery:

(1) How the backup works
If no mode is specified during the program startup phase, Innobackupex will start in Backup mode by default.
By default, this script starts xtrabackup with the--suspend-at-end option, and then xtrabackup the program to start copying InnoDB data files. When the Xtrabackup program finishes executing, Innobackupex will find that Xtrabackup created the Xtrabackup_suspended_2 file, and then executes the flush TABLES with READ LOCK, This statement reads locks on all database tables. It then starts copying other types of files.
If--ibbackup is not specified, Innobackupex will attempt to determine the binary of the xtrabackup used. The logic for determining binary is as follows: first determine if the Xtrabackup_binary file exists in the backup directory, and if so, this script will determine the xtrabackup binary used by this file. Otherwise, the script will attempt to connect to database server and determine binary through the server version. If the connection cannot be established, the xtrabackup will fail and you need to specify the binary file yourself.
When binary is determined, it checks to see if the connection to the database server can be established. Its execution logic is: Establish a connection, execute a query, close the connection. If everything works, Xtrabackup will start as a child process.
FLUSH TABLES with READ Lock is intended to back up MyISAM and other non-innodb types of tables, which are executed after Xtrabackup has backed up InnoDB data and log files. After this, the. frm will be backed up. MRG,. MYD,. MYI,. TRG,. TRN,. Arm. ARZ,. Csm. CSV,. Par, and. Opt types of files.
When all the above files have been backed up, the Innobackupex script will resume the execution of the xtrabackup and wait for it to back up the transaction log files generated during the above logical execution. Next, the table is unlocked, slave is started, and the connection to the server is closed. Next, the script will delete the Xtrabackup_suspended_2 file, allowing the xtrabackup process to exit.

(2) How the recovery works
In order to restore a backup, Innobackupex needs to start with the--copy-back option.
Innobackupex will first read the following variables through the my.cnf file: DataDir, Innodb_data_home_dir, Innodb_data_file_path, Innodb_log_group_home_dir, and determine that these directories exist.
Next, the script will first copy the MyISAM table, index file, and other types of files (such as. frm,. MRG,. MYD,. MYI,. TRG,. TRN,. Arm. ARZ,. Csm. CSV, par and. opt files), then copy the InnoDB table data file and finally copy the log file. The copy execution will retain the file attributes, and you may need to change the file's Owener (such as user changes from copy files to MySQL users) before starting MySQL with a backup file.
----------------------------------------------------------------------------------------------------------- ----------------------------------------

Ii. Innobackupex deployment of backup environments for MySQL databases


Iii. Summary of the use of Innobackupex

MySQL uses Innobackupex online backup scenario (full + incremental) operation record

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.