Percona XtraBackup 2.4 Documentation, Release 2.4.7
of writes that go to the transactional logs, and will hit an error when the log records are overwritten before they could
be read.
After the backup is finished, the target directory will contain files such as the following, assuming you have a single
InnoDB table test.tbl1 and you are using MySQL’s innodb_file_per_table option:
$ ls -lh /data/backups/
total 182M
drwx------ 7 root root 4.0K Sep 6 10:19 .
drwxrwxrwt 11 root root 4.0K Sep 6 11:05 ..
-rw-r----- 1 root root 387 Sep 6 10:19 backup-my.cnf
-rw-r----- 1 root root 76M Sep 6 10:19 ibdata1
drwx------ 2 root root 4.0K Sep 6 10:19 mysql
drwx------ 2 root root 4.0K Sep 6 10:19 performance_schema
drwx------ 2 root root 4.0K Sep 6 10:19 sbtest
drwx------ 2 root root 4.0K Sep 6 10:19 test
drwx------ 2 root root 4.0K Sep 6 10:19 world2
-rw-r----- 1 root root 116 Sep 6 10:19 xtrabackup_checkpoints
-rw-r----- 1 root root 433 Sep 6 10:19 xtrabackup_info
-rw-r----- 1 root root 106M Sep 6 10:19 xtrabackup_logfile
The backup can take a long time, depending on how large the database is. It is safe to cancel at any time, because it
does not modify the database.
The next step is getting your backup ready to be restored.
Preparing a backup
After you made a backup with the xtrabackup --backup option, you’ll first need to prepare it in order to restore
it. Data files are not point-in-time consistent until they’ve been prepared, because they were copied at different times
as the program ran, and they might have been changed while this was happening. If you try to start InnoDB with these
data files, it will detect corruption and crash itself to prevent you from running on damaged data. The xtrabackup
--prepare step makes the files perfectly consistent at a single instant in time, so you can run InnoDB on them.
You can run the prepare operation on any machine; it does not need to be on the originating server or the server to
which you intend to restore. You can copy the backup to a utility server and prepare it there.
Note: You can prepare a backup created with older Percona XtraBackup version with a newer one, but not vice versa.
Preparing a backup on an unsupported server version should be done with the latest Percona XtraBackup release
which supports that server version. For example, if one has a backup of MySQL 5.0 created with Percona XtraBackup
1.6, then preparing the backup with Percona XtraBackup 2.3 is not supported, because support for MySQL 5.0 was
removed in Percona XtraBackup 2.1. Instead, the latest release in the 2.0 series should be used.
During the prepare operation, xtrabackup boots up a kind of modified InnoDB that’s embedded inside it (the li-
braries it was linked against). The modifications are necessary to disable InnoDB’s standard safety checks, such as
complaining that the log file isn’t the right size, which aren’t appropriate for working with backups. These modifica-
tions are only for the xtrabackup binary; you don’t need a modified InnoDB to use xtrabackup for your backups.
The prepare step uses this “embedded InnoDB” to perform crash recovery on the copied data files, using the copied log
file. The prepare step is very simple to use: you simply run xtrabackup with the xtrabackup --prepare
option and tell it which directory to prepare, for example, to prepare the previously taken backup run:
$ xtrabackup --prepare --target-dir=/data/backups/
4.1. The Backup Cycle - Full Backups 16