The innobackupex program is a symlink to the xtrabackup C program. It lets you perform point-in-time backups of InnoDB / XtraDB tables together with the schema definitions, MyISAM tables, and other portions of the server. In previous versions innobackupex was implemented as a Perl script.
Warning: The innobackupex program is deprecated. Please switch to xtrabackup
# prepare the base backup xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base
# apply the first incremental backup to the full backup xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base --incremental-dir=/data/backups/inc1
# Preparing the second incremental backup xtrabackup --prepare --target-dir=/data/backups/base --incremental-dir=/data/backups/inc2
The xtrabackup –prepare step for incremental backups is not the same as for full backups. In full backups, two types of operations are performed to make the database consistent: committed transactions are replayed from the log file against the data files, and uncommitted transactions are rolled back. You must skip the rollback of uncommitted transactions when preparing an incremental backup, because transactions that were uncommitted at the time of your backup may be in progress, and it’s likely that they will be committed in the next incremental backup. You should use the xtrabackup –apply-log-only option to prevent the rollback phase.
如果看到如下的 warnings about tables that don’t exist 日志是正常的。
1 2 3 4 5
InnoDB: Reading tablespace information from the .ibd files... 101107 22:31:30 InnoDB: Error: table 'test1/t' InnoDB: in InnoDB data dictionary has tablespace id 6, InnoDB: but tablespace with that id or name does not exist. It will be removed from ˓→data dictionary.
Advanced Features
Throttling Backups
1
xtrabackup --throttle
–throttle=# This option limits the number of chunks copied per second. The chunk size is 10 MB. To limit the bandwidth to 10 MB/s, set the option to 1: –throttle=1.
Note: innobackupex –redo-only should be used when merging all incrementals except the last one. That’s why the previous line doesn’t contain the innobackupex –redo-only option. Even if the innobackupex –redo-only was used on the last step, backup would still be consistent but in that case server would perform the rollback phase.
Once you merge the base with all the increments, you can prepare it to roll back the uncommitted transactions: