Documentation Home
MySQL Enterprise Backup 3.12 User's Guide
Related Documentation Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb
HTML Download (TGZ) - 176.5Kb
HTML Download (Zip) - 202.1Kb


5.2 Performing a Restore Operation

The mysqlbackup commands to perform a restore operation are copy-back-and-apply-log and copy-back (for directory backup only; see Section 5.1, “Preparing the Backup to be Restored”). Normally, the restoration process requires the database server to be already shut down (or, at least not operating on the directory you are restoring the data to), except for restorations of backups created with the --use-tts option; see explanations below. The process copies the data files, logs, and other backed-up files from the backup directory back to their original locations, and performs any required post-processing on them.

Example 5.4 Shutting Down and Restoring a Database

mysqladmin --user=root --password shutdown
mysqlbackup --defaults-file=/usr/local/mysql/my.cnf \
  --backup-dir=/export/backups/full \
    copy-back

Note

The restored data includes the backup_history table, where MySQL Enterprise Backup records details of each backup. The table allows you to perform future incremental backups using the --incremental-base=history:last_backup option.

See Section 4.2.3, “Restoring a Database” for an explanation of the important options used in a restore operation like --defaults-file, --datadir, --backup-image, and --backup-dir.

Important

When performing a restore, make sure the target directories for restore data are all clean, containing no old or unwanted data files (this might require manual removal of files at the locations specified by the --datadir, --innodb_data_home_dir, --innodb_log_group_home_dir, and --innodb_undo_directory options). The same cleanup is not required for restoring backups created with the--use-tts option (in which case other requirements described in Section 5.2.4, “Restoring Backups Created with the --use-tts Option” apply though).

Before restoring a hot directory backup using the copy-back command, the backup has to be prepared and made consistent using the apply-log command. See Section 5.1, “Preparing the Backup to be Restored” for details. You can combine the apply-log and the copy-back operations (as well as a number of other operations, depending on the kind of backup you are restoring) into a single step by using the copy-back-and-apply-log option instead:

Example 5.5 Restoring a Backup Directory using copy-back-and-apply-log

mysqlbackup --defaults-file=<my.cnf> \
  --backup-dir=/export/backups/full \
copy-back-and-apply-log

The same command is typically used for single-file backups to perform the same functions:

Example 5.6 Restoring a Single-file Backup using copy-back-and-apply-log

mysqlbackup --defaults-file=<my.cnf> -uroot --backup-image=<image_name> \
  --backup-dir=<backupTmpDir> --datadir=<restoreDir> copy-back-and-apply-log

The --backup-dir option specifies a temporary directory into which temporary output, status files, and backup metadata are be saved.


Note

Due to a known issue (Bug# 20485910), restoring a partial image backup created with MySQL Enterprise Backup 3.11 or earlier requires using the --force option.

The following subsections describe a number of different scenarios for restoring a backup.