Xtrabackup is an open-source backup software for Percona, a hot standby innodb,xtradb,myism (lock table) that can be seen as a free alternative to InnoDB hotbackup.
The following is a brief introduction to the use of Xtrabackup:
① installs the xtrabackup, to download the appropriate version of Linux xtrabackup to the official website. The RPM package format can be downloaded by itself and can be installed directly RPM–IVH after downloading. Errors may occur during the installation process, and we need to resolve related dependency issues.
② start a backup of MySQL.
Create a backup folder
Mkidr/backup
innobackupex–user=root–password=***--host=***/backup
The database completes the backup. After the backup is complete, a timestamp-first backup folder is automatically created under the/backup folder. Include several files in the folder
BACKUP-MY.CNF--------------The configuration option information used by the backup command.
Xtrabackup_binlog_info---------The binary log used when backing up, and the binary location when backing up.
Xtrabackup_checkpoints---------Backup type, backup status, backup scope information (LSN log information number).
Xtrabackup_info-------------------Backup Information Statistics, more useful, can be used to do instant point restore.
and other data information, not in the one by one introduction.
When the full backup is complete, the following incremental backups are made.
Innobackupex–incremental/backup--incremental-basedir=/backup/****
Note: The-incremental-basedir file here refers to the directory after the last incremental backup.
③ Preparing backup files
innobackupex–apply-log–redo-only/backup/***/Full backup file directory
innobackupex–apply-log–redo-only/backup/***--incremental-dir=/backup/***-----à incremental directory where.
There may be a second, one analogy.
Note that there are only-redo-only parameters, because during an incremental backup, those transactions that were not committed may have been submitted. So just need to synchronize the contents of the transaction log into the data file.
④ Simulating database corruption
Before this, look at the current database log with that. and copy binary log files to a secure directory.
cp/data/mydata/mysql-bin.00000*/backup/
Service Mysqld Stop
rm–rf/data/mydata/*
Killall mysqld----à kills all the MySQL processes. Ensure that no MySQL process is running at all.
innobackupex–copy-back/backup/****/main backup directory, two incremental directories are not necessary, because during the preparation of the backup directory, two directories have been merged into the home directory.
After the document has been tested, change the owner and owner group under the data directory
Chown–r mysql.mysql/data/mydata/*
Perform a restore of the binary log.
First, open the Xtrabackup_info file for the last delta log. View the end-time inside, which is the time that the binary log starts to restore.
Mysqlbinlog--start-datetime= ' * * * * * * */backup/mysql-bin.00000* >/backup/1.sql
Start MySQL below
Service mysqld Start
MySQL </backup/1.sql------------à to perform a binary completion restore, during the restore process, close the binary log file after the restore is complete, after you turn on this feature. Close the method mysql> set sql_log_bin=0, open when the corresponding value is changed to 1 is good.
OK, innobackup the way to restore MySQL first.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Xtrabackup backing up the MySQL database