Documentation Home
MySQL Enterprise Backup 9.5 User's Guide
Related Documentation Download this Manual
PDF (US Ltr) - 1.3Mb
PDF (A4) - 1.3Mb


5.1 Performing a Restore Operation

Themysqlbackup commands to perform a restore operation arecopy-back-and-apply-log andcopy-back (for directory backup only; seeSection 5.1.7, “Advanced: Preparing and Restoring a Directory Backup”). 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 apartial restore. 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.1 Restoring a Database Server

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

Thecopy-back-and-apply-log command achieves two things:

  • Extracts the backup from the image file and copies it to the data directory on the server to be restored.

  • Performs anapply log operation to the restored data to bring them up-to-date.

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

The restored data includes thebackup_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 | last_full_backup} option.

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 partial restores, for which other requirements described inSection 5.1.4, “Table-Level Recovery (TLR)” apply.

  • After a full restore, depending on how you are going to start the restored server, you might need to adjust the ownership of the restored data directory. For example, if the server is going to be started by the usermysql, use the following command to change the owner attribute of the data directory and the files under it to themysql user, and the group attribute to themysql group.

    $ chown -R mysql:mysql/path/to/datadir

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