There are different ways to use incremental backups to restore a
database under different scenarios. The preferred method is to
first restore the full backup and make it up-to-date to the time
at which the full backup was performed using the
Example 5.5, “Restoring a Backup Directory using
Example 5.6, “Restoring a Single-file Backup using
on how to do it); then use
again to restore the incremental backup image on top of the full
backup that was just restored:
Example 5.9 Restoring an Incremental Backup Image
mysqlbackup --defaults-file=<my.cnf> -uroot --backup-image=<inc_image_name> \ --backup-dir=<incBackupTmpDir> --datadir=<restoreDir> --incremental \ copy-back-and-apply-log
In this example, the incremental backup image named
<inc_image_name> is restored to
<restoreDir> on the server (where
the full backup that the incremental backup image was based on
has already been restored). The
--backup-dir option is
used to specify the temporary directory into which temporary
output, status files, and backup metadata are saved. Repeat the
step with other incremental backup images that you have, until
the data has been restored to a desired point in time.
Alternatively you can bring your full backup up-to-date with your incremental backup. First, apply to the full backup any changes that occurred while the backup was running:
$ mysqlbackup --backup-dir=/full-backup/2010-12-08_17-14-11 apply-log ..many lines of output... 101208 17:15:10 mysqlbackup: Full backup prepared for recovery successfully! 101208 17:15:10 mysqlbackup: mysqlbackup completed OK!
Then, we apply the changes from the incremental backup:
$ mysqlbackup --incremental-backup-dir=/incr-backup/2010-12-08_17-14-48 \ --backup-dir=/full-backup/2010-12-08_17-14-11 apply-incremental-backup ...many lines of output... 101208 17:15:12 mysqlbackup: mysqlbackup completed OK!
Now, the data files in the full backup directory are fully up-to-date, as of the time of the last incremental backup. You can keep updating it with more incremental backups, so it is ready to be restored anytime.
When an incremental backup is being restored using either the
the binary log (and also the relay log, in the case of a slave
server), if included in the incremental backup, is also restored
to the target server by default. This default behavior is
overridden when either (1) the
--skip-binlog option (or the
--skip-relaylog option for the relay
log) is used with the restore command, or (2) if the full backup
the incremental backup was based on or any prior incremental
backup that came in between the full backup and this incremental
backup has the binary log (or relay log) missing.
See Section 4.3.2, “Making a Differential or Incremental Backup”, and Section 14.7, “Incremental Backup Options”, for more details on incremental backups.