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


4.1.1.3 Restore an Existing Backup

Restores the data files from a backup to their original locations within the database server. The MySQL instance must be shut down first before a restore operation. The options datadir, innodb_log_files_in_group, and innodb_log_file_size must be specified either in the target server's configuration file, in the file specified by the --defaults-file option, or as command-line options. For usage and examples, see Chapter 5, Recovering or Restoring a Database.

mysqlbackup [STD-OPTIONS]
            [SERVER-REPOSITORY-OPTIONS]
            [--backup-dir=PATH]
            [MESSAGE-LOGGING-OPTIONS]
            [PROGRESS-REPORT-OPTIONS]
            copy-back

mysqlbackup [STD-OPTIONS]
            [--backup-image=IMAGE]
            [--backup-dir=PATH]
            [MESSAGE-LOGGING-OPTIONS]
            [PROGRESS-REPORT-OPTIONS]
            copy-back-and-apply-log 
  • copy-back

    Restores files from a backup to their original locations within the MySQL server or to locations on another MySQL server instance.

    Some clean-up efforts on the target directory for restoration might be needed before preforming a full restore (for example, when the backup data is used to set up a new MySQL server or used to replace all data of an existing MySQL server). See Section 5.2, “Performing a Restore Operation” for details.

    There are some special requirements when restoring backups created with the --use-tts option; see Restoring Backups Created with the --use-tts Option for details.

  • copy-back-and-apply-log

    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 an apply-log operation to the restored data to bring them up-to-date. Comparing with a multi-step approach (which typically consists of performing the successive steps of extract, uncompress and apply-log (for restoring compressed image) or apply-log (for uncompressed image), and copy-back for restoring a single-file backup), the option makes the restoration process simpler and faster, and also saves the disk space required.

    At the end of the copy-back-and-apply-log operation, the file backup_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.

    To restore a compressed directory or image, include the --uncompress option in the command line.

    To restore an incremental backup using the option, make sure the following requirements are followed:

    Also note the following:

    • Backups created with the --skip-unused-pages option cannot be restored using copy-back-and-apply-log.

    • For image backups taken with MySQL Enterprise Backup 3.8.2 or earlier, per-table .ibd files pointed to by .isl files in a backup are restored to the server's data directory rather than the locations pointed to by the .isl files.

    • When restoring an image backup, temporary metadata files are extracted to the folder specified by the --backup-dir option.

    The following are some sample command sequences for taking a backup and restoring it with the copy-back-and-apply-log option:

    • For a normal, full backup:

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

    • For a compressed backup:

      mysqlbackup -uroot --backup-dir=<backupDir> --compress backup
      mysqlbackup --defaults-file=<my.cnf> -uroot --backup-dir=<backupDir> --datadir=<restoreDir> \
        --uncompress copy-back-and-apply-log
      

    • For a compressed image backup:

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

    • For an incremental image backup:

      mysqlbackup -uroot --incremental-backup-dir=<incBackupTmpDir> --start-lsn="1234" --incremental \
        --backup-image=<inc_image_name> backup-to-image
      # To specify the incremental backup directory for copy-back-and-apply-log, use either --incremental-backup-dir:
      mysqlbackup --defaults-file=<backupDir>/backup-my.cnf -uroot --backup-image=<inc_image_name> \
        --incremental-backup-dir=<incBackupTmpDir> --datadir=<restoreDir> --incremental \
        copy-back-and-apply-log
      # Or use --backup-dir for the same purpose:
      mysqlbackup --defaults-file=<backupDir>/backup-my.cnf -uroot --backup-image=<inc_image_name> \
        --backup-dir=<incBackupTmpDir> --datadir=<restoreDir> --incremental \
        copy-back-and-apply-log
      

Warning

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.


User Comments
Sign Up Login You must be logged in to post a comment.