The restore operations restores the data files from a backup to
their original locations on the database server, or to other
desired locations. 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 a partial
restore. The option
datadir
must be specified
either in the file specified by the
--defaults-file
option or as a
command-line option. For usage examples, see
Chapter 5, Recovering or Restoring a Database Server.
mysqlbackup [STD-OPTIONS]
[SERVER-REPOSITORY-OPTIONS]
[--backup-image=IMAGE]
[--backup-dir=PATH]
[--uncompress]
[MESSAGE-LOGGING-OPTIONS]
[PARTIAL-BACKUP-RESTORE-OPTIONS]
[PROGRESS-REPORT-OPTIONS]
[ENCRYPTION-OPTIONS]
[CLOUD-STORAGE-OPTIONS]
[ENCRYPTED-INNODB-OPTIONS]
copy-back-and-apply-log
mysqlbackup [STD-OPTIONS]
[SERVER-REPOSITORY-OPTIONS]
[--backup-dir=PATH]
[--uncompress]
[MESSAGE-LOGGING-OPTIONS]
[PARTIAL-BACKUP-RESTORE-OPTIONS]
[PROGRESS-REPORT-OPTIONS]
[CLOUD-STORAGE-OPTIONS]
[ENCRYPTED-INNODB-OPTIONS]
copy-back
In a single step, restores a single-file backup specified by the
--backup-image
option or a backup from the directory specified by the--backup-dir
option to a server's data directory and performs anapply-log
operation to the restored data to bring them up-to-date. Comparing with a multi-step approach for restoring a single-file backup (which typically consists of performing the successive steps of extract, uncompress, apply-log, and copy-back for restoring compressed image, or extract ,apply-log, and copy-back for uncompressed image), the command makes the restoration process simpler and faster, and also saves the disk space required.The following are some special requirements for different kinds of backup restoration using
copy-back-and-apply-log
:For MySQL Enterprise Backup 8.0.20 and earlier: To restore a compressed directory or image, include the
--uncompress
option in the command line (the option is no longer required for MySQL Enterprise Backup 8.0.21 and later).To restore a single-file backup, besides specifying the location of the backup image with the
--backup-image
option, also supply with the--backup-dir
option the location of a folder that will be used for storing temporary files produced during the restoration process.To restore a single-file incremental backup, assuming the full backup (on which the incremental backup was based) has already been restored:
For MySQL Enterprise Backup 8.0.20 and earlier: Include the
--incremental
option in the command line (the option is no longer required for MySQL Enterprise Backup 8.0.21 and later).For MySQL Enterprise Backup 8.0.20 and earlier: Include the
--uncompress
option in the command line if the incremental backup has been created with the--compress
option (the option is no longer required for MySQL Enterprise Backup 8.0.21 and later).Specifies the location of the incremental backup image with the
--backup-image
option.Supplies with the
--backup-dir
option the location of a folder that will be used for storing temporary files produced during the restoration process.
Advanced: To restore an incremental backup directory, assuming the full backup (on which the incremental backup was based) has already been restored:
For MySQL Enterprise Backup 8.0.20 and earlier: Include the
--incremental
option in the command line (the option is no longer required for MySQL Enterprise Backup 8.0.21 and later).Use either the
--backup-dir
or--incremental-backup-dir
option to specify the incremental backup directory.
To restore selected tables:
See the general requirements described in Section 5.1.4, “Table-Level Recovery (TLR)”.
When restoring a single-file backup created with the option setting
--use-tts=with-minimum-locking
, the folder specified with--backup-dir
is also used for extracting temporarily all the tables in the backup and for performing anapply-log
operation to make the data up-to-date before restoring them to the server's data directory.Advanced: When restoring a backup directory created with the option
--use-tts=with-minimum-locking
, anapply-log
operation will be performed on the backup directory. That means the backup taken will be altered during the process, and users might want to make an extra copy of the backup directory before proceeding with the restoration, in order to prevent the loss of backup data in case something goes wrong.
Also note that:
Backups created with the
--skip-unused-pages
option cannot be restored usingcopy-back-and-apply-log
.
At the end of the
copy-back-and-apply-log
operation, the filebackup_variables.txt
is being created or updated in the data directory. This file contains metadata about the restored contents and is being used by successive single-step restores of incremental backups; it should not be deleted or modified by users.For some sample commands for restoring different kinds of backups with the
copy-back-and-apply-log
command, see Section 5.1, “Performing a Restore Operation”.Restores files from a directory backup to their original locations within the MySQL server.
Before restoring a hot backup using the
copy-back
command, the backup has to be prepared and made consistent using theapply-log
command. See Section 5.1.7, “Advanced: Preparing and Restoring a Directory Backup” for details. You can also performapply-log
andcopy-back
together with a singlecopy-back-and-apply-log
command.Some clean-up efforts on the target directory for restoration might be needed before performing a full restore (for example, when the backup data is used to set up a new MySQL server or to replace all data of an existing MySQL server). See the discussions here for details.
There are some special requirements when restoring selected tables from backups; see Section 5.1.4, “Table-Level Recovery (TLR)” for details.
When restoring a server for
replication purpose, if
the backed-up server has used the
innodb_undo_directory
option to
put the undo logs outside of the data directory, when using
the file server-my.cnf
or
server-all.cnf
for the
--defaults-file
option with
copy-back
or
copy-back-and-apply-log
, care
should be taken to configure correctly the
innodb_undo_directory
option in
the file. Otherwise, the data or log files on the original
server might be overwritten by accident.