Table of Contents
The mysqlbackup command is an easy-to-use tool for all backup and restore operations. During backup operations, mysqlbackup backs up:
All InnoDB tables and indexes, including:
The InnoDB system tablespace, which by default contains all the InnoDB tables.
Any separate data files produced under the InnoDB file-per-table setting. Each one contains one table and its associated indexes. Each data file can use either the original Antelope or the new Barracuda file format.
All MyISAM tables and indexes.
Tables managed by other storage engines.
Other files underneath the MySQL data directory, such as the
.frm files that record the structure of
each table.
In addition to creating backups, mysqlbackup can pack and unpack backup data, apply to the backup data any changes to InnoDB tables that occurred during the backup operation, and restore data, index, and log files back to their original locations.
Sample command line arguments to start mysqlbackup are:
# Information about data files can be retrieved through the database connection. # Specify connection options on the command line. mysqlbackup --user=dba --password --port=3306 \ --with-timestamp --backup-dir=/export/backups \ backup # Or we can include the above options in the configuration file # under [mysqlbackup], and just specify the configuration file # and the 'backup' operation. mysqlbackup --defaults-file=/usr/local/mysql/my.cnf backup # Or we can specify the configuration file as above, but # override some of those options on the command line. mysqlbackup --defaults-file=/usr/local/mysql/my.cnf \ --compress --user=backupadmin --password --port=18080 \ backup
The --user and the --password you
specify are used to connect to the MySQL server. This MySQL user
must have certain privileges in the MySQL server, as described in
Section 3.1.2, “Grant MySQL Privileges to Backup Administrator”.
The --with-timestamp option places the
backup in a subdirectory created under the directory you specified
above. The name of the backup subdirectory is formed from the date
and the clock time of the backup run.
For the meanings of other command-line options, see Section 5.1, “mysqlbackup Command-Line Options”. For information about configuration parameters, see Section 5.2, “Configuration Files and Parameters”.
Make sure that the user or the cron job running mysqlbackup has the rights to copy files from the MySQL database directories to the backup directory.
Make sure that your connection timeouts are long enough so that the command can keep the connection to the server open for the duration of the backup run. mysqlbackup pings the server after copying each database to keep the connection alive.
Although the mysqlbackup command backs up
InnoDB tables without interrupting database use, the final
stage that copies non-InnoDB files (such as MyISAM tables and
.frm files) temporarily puts the database
into a read-only state, using the statement FLUSH
TABLES WITH READ LOCK. For best backup performance
and minimal impact on database processing:
Do not run long SELECT queries or other
SQL statements at the time of the backup run.
Keep your MyISAM tables relatively small and primarily for read-only or read-mostly work.
Then the locked phase at the end of a
mysqlbackup run is short (maybe a few
seconds), and does not disturb the normal processing of
mysqld much. If the preceding conditions
are not met in your database application, use the
--only-innodb option to back up
only InnoDB tables, or use the
--no-locking option
to back up non-InnoDB files. Note that MyISAM,
.frm, and other files copied under the
--no-locking setting cannot be guaranteed to
be consistent, if they are updated during this final phase of
the backup.
For a large database, a backup run might take a long time. Always check that mysqlbackup has completed successfully, either by verifying that the mysqlbackup command returned exit code 0, or by observing that mysqlbackup has printed the text “mysqlbackup completed OK!”.
The mysqlbackup command is not the same as the former “MySQL Backup” open source project from the MySQL 6.0 source tree. The MySQL Enterprise Backup product supersedes the MySQL Backup initiative.
Schedule backups during periods when no DDL operations involving tables are running. See Section A.1, “Limitations of MySQL Enterprise Backup” for restrictions on backups at the same time as DDL operations.
The following sections describe the different modes of operation for mysqlbackup, and explain in details the applicable options for each of the modes of operation and for different situations.
The table below list all the command options for mysqlbackup. Use the hotlinks at the option names to jump to the detailed descriptions for the options.
The command options can also be specified in configuration files; see explanations in Section 5.2, “Configuration Files and Parameters”. The mysqlbackup command follows MySQL standard practice for handling duplicate options, whether specified in a configuration file, on the command line, or both. Options are processed first from configuration files, then from the command line. If an option is specified more than once, the last instance takes precedence.
Table 5.1 List of All Options
| Format | Description | Introduced |
|---|---|---|
| --backup-dir | The directory to store the backup data. | |
| --backup-image | Specifies the path name of the backup image. | |
| --backup_innodb_checksum_algorithm | The name of the checksum algorithm used for validating InnoDB tablespaces. | |
| --backup_innodb_data_file_path | Specifies Innodb system tablespace files' path and size in backup. | |
| --backup_innodb_data_home_dir | Backup base directory for all InnoDB data files in the system tablespace. | |
| --backup_innodb_log_file_size | The size in bytes of each InnoDB backup log file. | |
| --backup_innodb_log_files_in_group | Number of InnoDB log files in backup. | |
| --backup_innodb_log_group_home_dir | Backup directory for InnoDB log files. | |
| --backup_innodb_page_size | The page size for all InnoDB tablespaces in a MySQL instance. | |
| --backup_innodb_undo_directory | The relative or absolute directory path where InnoDB creates separate tablespaces for the undo logs. | |
| --backup_innodb_undo_logs | Number of rollback segments in the system tablespace that InnoDB uses within a transaction. | |
| --backup_innodb_undo_tablespaces | The number of tablespace files that the undo logs are divided between when a non-zero innodb_undo_logs setting is used. | |
| --character-sets-dir | Directory for character set files. | |
| --cloud-access-key-id | AWS access key ID for logging onto Amazon S3. | |
| --cloud-aws-region | Region for Amazon Web Services that mysqlbackup access for S3. | |
| --cloud-bucket | The storage bucket on Amazon S3 for the backup image. | |
| --cloud-object-key | The Amazon S3 object key for the backup image. | |
| --cloud-proxy | Proxy address and port number for overriding the environment's default proxy settings for accessing cloud service. | |
| --cloud-secret-access-key | AWS secret access key. | |
| --cloud-service | Cloud service for data backup or restoration. | |
| --cloud-trace | Print trace information for cloud operations. | |
| --comments | Specifies comments string. | |
| --comments-file | Specifies path to comments file. | |
| --compress | Create backup in compressed format. | |
| --compress-level | Specifies the level of compression. | |
| --compress-method | Specifies the compression algorithm. | |
| --connect-if-online | Use connection only if available. | |
| --connect_timeout | Connection timeout in seconds. | |
| --databases | [Legacy] Specifies the list of non-InnoDB tables to back up. | |
| --databases-list-file | [Legacy] Specifies the pathname of a file that lists the non-InnoDB tables to be backed up. | |
| --datadir | Path to mysql server data directory. | |
| --debug | Print debug information. | |
| --decrypt | Decrypt backup image written in an MEB Secure File. | |
| --default-character-set | Set the default character set. | |
| --defaults-extra-file | Read this file after the global files are read. | |
| --defaults-file | Only read default options from the given file. | |
| --defaults-group-suffix | Also read option groups with the usual names and a suffix of str. | |
| --disable-manifest | Disable generation of manifest files for a backup operation. | |
| --dst-entry | Used with single-file backups to extract a single file or directory to a user-specified path. | |
| --encrypt | Encrypt backup image and write it in an MEB Secure File. | |
| --exclude-tables | Exclude in a backup (or in a restore of a TTS backup) tables whose names match the regular expression REGEXP. | |
| --exec-when-locked | Execute the specified utility when all tables are locked near the end of the execution. | |
| --force | Force overwriting of data, log, or image files, depending on the operation. | |
| --help | Display help. | |
| --host | Host name to connect. | |
| --include | [Legacy] Backup only those per-table innodb data files which match the regular expression REGEXP. | |
| --include-tables | Include in a backup (or in a restore of a TTS backup) tables which match the regular expression REGEXP. | |
| --incremental | Specifies that the associated backup or backup-to-image operation is incremental. | |
| --incremental-backup-dir | Specifies the location under which to store data from an incremental backup. | |
| --incremental-base | The specification of base backup for --incremental option. | |
| --incremental-with-redo-log-only | Specifies the incremental backup of InnoDB tables to be based on copying redo log to the backup, without including any InnoDB datafiles in the backup. | |
| --innodb_checksum_algorithm | The name of the checksum algorithm used for validating InnoDB tablespaces. | |
| --innodb_data_file_path | Specifies InnoDB system tablespace files' path and size. | |
| --innodb_data_home_dir | Specifies base directory for all InnoDB data files in the shared system tablespace. | |
| --innodb_log_file_size | The size in bytes of each InnoDB log file in the log group. | |
| --innodb_log_files_in_group | The number of InnoDB log files. | |
| --innodb_log_group_home_dir | The directory path to InnoDB log files. | |
| --innodb_page_size | The page size for all InnoDB tablespaces in a MySQL instance. | |
| --key | The symmetric key used for encryption and decryption. | |
| --key-file | The pathname of a file that contains the symmetric key used for encryption and decryption. | |
| --limit-memory | The memory in MB available for the MEB operation. | |
| --log-bin-index | Specifies the absolute path of the index file on the MySQL server that lists all the used binary log files (for MySQL 5.5, and for all offline backups). | 3.11.0 |
| --login-path | Read options from the named login path in the .mylogin.cnf login file. | |
| --master-info-file | Specifies the absolute path of the information file in which a slave records information about its master (for offline backups of slave servers only). information file. | 3.11.0 |
| --messages-logdir | Specifies the path name of an existing directory for storing the message log. | |
| --no-connection | Do not connect to server. | |
| --no-defaults | Do not read default options from any given file. | |
| --no-history-logging | Disable history logging even if connection is available. | |
| --no-locking | Disable locking of tables even if connection is available. | |
| --number-of-buffers | Specifies the exact number of memory buffers to be used for the backup operation. | |
| --on-disk-full | Specifies the behavior when a backup process encounters a disk-full condition. | |
| --only-innodb | Back up only InnoDB data and log files. | |
| --only-innodb-with-frm | [Legacy] Back up only InnoDB data, log files, and the .frm files associated with the InnoDB tables. | |
| --only-known-file-types | Includes only files of a list of known types in the backup. | |
| --optimistic-busy-tables | Perform an optimistic backup, using the regular expression specified with the option to select tables that will be skipped in the first phase of an optimistic backup. | 3.11.0 |
| --optimistic-time | Perform an optimistic backup with the value specified with the option as the optimistic time—a time after which tables that have not been modified are believed to be inactive tables. | 3.11.0 |
| --page-reread-count | Maximum number of page re-reads. | |
| --page-reread-time | Wait time before a page re-read. | |
| --password | Connection password. | |
| --pipe | alias for –protocol=pipe. | |
| --port | TCP portnumber to connect to. | |
| --print-defaults | Print a list of option values supplied by defaults files and exit. | |
| --process-threads | Specifies the number of process-threads for the backup operation. | |
| --progress-interval | Interval between progress reports in seconds. | |
| --protocol | Connection protocol. | |
| --read-threads | Specifies the number of read-threads for the backup operation. | |
| --relay-log-index | Specifies the absolute path of the index file on the MySQL server that lists all the used relay log files (for offline backups of slave servers only). | 3.11.0 |
| --relaylog-info-file | Specifies the absolute path of the information file in which a slave records information about the relay logs (for offline backups of slave servers only). | 3.11.0 |
| --sbt-database-name | Used as a hint to the Media Management Software (MMS) for the selection of media and policies for tape backup. | |
| --sbt-environment | Comma separated list of environment variable assignments to be given to the SBT library. | |
| --sbt-lib-path | Path name of the SBT library used by software that manages tape backups. | |
| --secure-auth | Refuse client connecting to server if it uses old (pre-4.1.1) protocol. | |
| --shared-memory-base-name | It designates the shared-memory name used by a Windows server to permit clients to connect using shared memory (Windows only). | |
| --show-progress | Instructs mysqlbackup to periodically output short progress reports known as progress indicators on its operation. | |
| --skip-binlog | Do not include binary log files during backup, or do not restore binary log files during restore. | 3.11.0 |
| --skip-messages-logdir | Disable logging to teelog file. | |
| --skip-relaylog | Do not include relay log files during backup, or do not restore relay log files during a restore. | 3.11.0 |
| --skip-unused-pages | Skip unused pages in tablespaces when backing up InnoDB tables. | |
| --slave-info | Capture information needed to set up an identical slave server. | |
| --sleep | Time to sleep in milliseconds after copying each 1MB of data. | |
| --socket | Socket file to use to connect. | |
| --src-entry | Identifies a file or directory to extract from a single-file backup. | |
| --ssl | Enable SSL for connection (automatically enabled with other --ssl- flags). | |
| --ssl-ca | CA file in PEM format (implies –ssl). | |
| --ssl-capath | CA directory (check OpenSSL docs,implies --ssl). | |
| --ssl-cert | X509 cert in PEM format (implies --ssl). | |
| --ssl-cipher | SSL cipher to use (implies --ssl). | |
| --ssl-key | X509 key in PEM format (implies --ssl). | |
| --ssl-verify-server-cert | Verify server's "Common Name" in its cert against hostname used when connecting. | |
| --start-lsn | Specifies the highest LSN value included in a previous backup. | |
| --suspend-at-end | Pauses the mysqlbackup command when the backup procedure is close to ending. | |
| --trace | Trace level of messages by mysqlbackup. | |
| --uncompress | Uncompress the compressed backup before an apply-log, copy-back, or copy-back-and-apply-log operation. | |
| --use-tts | Enable selective backup of InnoDB tables using transportable tablespaces (TTS). | |
| --user | Database user name to connect. | |
| --verbose | Print more verbose information. | |
| --version | Display version information. | |
| --with-timestamp | Create a subdirectory underneath the backup directory with a name formed from the timestamp of the backup operation. | |
| --write-threads | Specifies the number of write-threads for the backup operation. |
These options represent the major operations or modes for the mysqlbackup command. Only one can be specified for each mysqlbackup invocation, and the name is not preceded by any dashes.
Each of these major options has its own set of required or
allowed command parameters. For example, the
backup* options require connection information
to the database server. The apply-log, and
other options that operate on the backup data after it is
produced, require options to specify where the backup data is
located.
The major groups of subcommands are:
Backup operations: backup,
backup-and-apply-log,
backup-to-image
Apply operations: apply-log,
apply-incremental-backup
Restore operations: copy-back,
copy-back-and-apply-log
Validation operation: validate
Single-file backup operations:
image-to-backup-dir,
backup-dir-to-image,
list-image,
extract
The backup operations are the most frequently performed tasks
by MySQL Enterprise Backup. Various kinds of backups can be
performed by adding different options, like using
--compress or
--incremental for compressed or
incremental backups. Here is the syntax for the
mysqlbackup command for performing a backup
operation:
mysqlbackup [STD-OPTIONS] [CONNECTION-OPTIONS] [SERVER-REPOSITORY-OPTIONS] [BACKUP-REPOSITORY-OPTIONS] [METADATA-OPTIONS] [COMPRESSION-OPTIONS] [SPECIAL-BACKUP-TYPES-OPTIONS] [INCREMENTAL-BACKUP-OPTIONS] [PARTIAL-BACKUP-RESTORE-OPTIONS] [SINGLE-FILE-BACKUP-OPTIONS] [PERFORMANCE-SCALABILITY-CAPACITY-OPTIONS] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS]backup|backup-and-apply-logmysqlbackup [STD-OPTIONS] [CONNECTION-OPTIONS] [SERVER-REPOSITORY-OPTIONS] [BACKUP-REPOSITORY-OPTIONS] [METADATA-OPTIONS] [COMPRESSION-OPTIONS] [SPECIAL-BACKUP-TYPES-OPTIONS] [INCREMENTAL-BACKUP-OPTIONS] [PARTIAL-BACKUP-RESTORE-OPTIONS] [SINGLE-FILE-BACKUP-OPTIONS] [PERFORMANCE-SCALABILITY-CAPACITY-OPTIONS] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]backup-to-image
backup-to-image
Produces a single-file backup rather than a directory
structure holding the backup files. Requires the
--backup-image option to
specify the destination file. Can be used to stream the
backup to a storage device or another system without ever
storing the data on the database server. You can specify
--backup-image=-, representing
standard output, allowing the output to be piped to
another command. To avoid mixing normal informational
messages with backup output, the --help
message, errors, alerts, and normal informational messages
are always printed to standard error.
Example 5.1 Simple Backup with Connection Parameters from Default Configuration File
The following example shows a minimal backup with the
mysqlbackup command, with any necessary
connection parameters for the database in the
[mysqlbackup] section of the default
MySQL configuration file:
mysqlbackup --backup-dir=/export/backups/latest backup
Example 5.2 Basic Incremental Backup
mysqlbackup --incremental --start-lsn=12345 --incremental-backup-dir=/path/to/incbackup backup
There is a separate directory dedicated to incremental
backup. Both this directory and the one for full backups can
be specified in the my.cnf file, and
the appropriate directory is used depending on the type of
backup. Both the incremental backup data and an earlier full
backup are needed to do a successful restore operation.
These operations bring the backup files up-to-date with any
changes to InnoDB tables that happened while the backup was in
progress. Although for convenience you can combine this
operation with the initial backup using the
backup-and-apply-log option, you
must run the steps separately when performing incremental or
compressed backups.
mysqlbackup [STD-OPTIONS] [--limit-memory=MB] [--uncompress] [--backup-dir=PATH] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS]apply-logmysqlbackup [STD-OPTIONS] [--incremental-backup-dir=PATH] [--backup-dir=PATH] [--limit-memory=MB] [--uncompress] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS]apply-incremental-backup
Example 5.3 Apply Log to Full Backup
mysqlbackup --backup-dir=/path/to/backup apply-log
It reads the backup-my.cnf file inside
backup-dir to understand the
backup. The my.cnf default files have
no effect other than supplying the
limit-memory=
value, which limits usage of memory while doing the
MBapply-log operation.
Because the apply-log operation does not apply to
incremental backups, no
incremental-backup-dir is needed
for this operation.
You can also perform apply-log and
copy-back (which restores the
prepared backup) together with a single
copy-back-and-apply-log command.
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 4, Recovering or Restoring a Database.
mysqlbackup [STD-OPTIONS] [SERVER-REPOSITORY-OPTIONS] [--backup-dir=PATH] [MESSAGE-LOGGING-OPTIONS] [PARTIAL-BACKUP-RESTORE-OPTIONS] [PROGRESS-REPORT-OPTIONS] [CLOUD-STORAGE-OPTIONS]copy-backmysqlbackup [STD-OPTIONS] [SERVER-REPOSITORY-OPTIONS] [--backup-image=IMAGE] [--backup-dir=PATH] [MESSAGE-LOGGING-OPTIONS] [PARTIAL-BACKUP-RESTORE-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]copy-back-and-apply-log
copy-back
Restores files from a backup to their original locations within the MySQL server.
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 4.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 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 option 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:
To restore a compressed directory or image, include
the --uncompress option
in the command line.
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 an incremental backup directory, assuming the full backup (on which the incremental backup was based) has already been restored:
Include the
--incremental
option in the command line.
Use either the
--backup-dir or
--incremental-backup-dir
option to specify the incremental backup
directory.
To restore a single-file incremental backup, besides
specifying the location of the incremental backup
image with the
--backup-image option,
also supply with the
--backup-dir or
--incremental-backup-dir
option the location of a folder that will be used
for storing temporary files produced during the
restoration process.
To restore a backup created with the
--use-tts option:
See the general requirements described in Restoring Backups Created with the --use-tts Option.
When restoring an image backup created with
the option setting
--use-tts=with-minimum-locking,
also supply with the
--backup-dir
option the location of a folder that will be
used for extracting temporarily all tables in
the backup and for performing an
apply-log
operation to make the data up-to-date before
restoring them to the server's data directory.
When restoring a backup directory created with
the option
--use-tts, an
apply-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 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 by
copy-back-and-apply-log
to the server's data directory rather than the
locations pointed to by the .isl files.
Due to a known issue, when restoring a compressed
backup created with MySQL Enterprise Backup 3.9 or earlier and
containing any InnoDB tables that were created on
the server as compressed tables (by using the
ROW_FORMAT=COMPRESSED option, the
KEY_BLOCK_SIZE= option, or both),
do not use
copy-back-and-apply-log;
instead, perform an
apply-log first, and
then a copy-back. See
entry for Bug# 17992297 in the
MySQL Enterprise Backup
3.10.0 changelog for details.
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.
For some sample commands for restoring different kinds of
backups with the
copy-back-and-apply-log
subcommand, see Section 4.2, “Performing a Restore Operation”.
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.
To ensure the integrity of the backup data, MySQL Enterprise Backup provides a
validate subcommand for validating
a backup by the checksum values of its data pages after the
backup is created or transferred to another system.
mysqlbackup [STD-OPTIONS] [--backup-dir=PATH][--backup-image=IMAGE] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS] [CLOUD-STORAGE-OPTIONS]validate
validate
Verifies that a backup is not corrupted, truncated, or damaged. This operation validates the checksum value for each data page in a backup.
To avoid spending excessive time and resources on files that are too heavily corrupted, mysqlbackup stops validating a .ibd file after more than twenty corrupted pages are found in it, and proceeds to the next file instead. In that case, the operation's summary will not give a full count of corrupted pages, but only says “at least 20 pages are corrupted.”
The operation also has the following limitations:
For any backup directory, the operation can only
validate the InnoDB data files
(ibdata* and
*.ibd files) in it. Problems
with other file types within a backup directory (for
example, .frm file corruptions)
are not detected.
If any .ibd or
.frm files are missing from a
backup directory during a backup or have been
deleted from a backup directory after the backup was
made, the validate operation will
not be able to detect the problem.
If a backup directory has been corrupted by removing
or truncating pages from any of the .ibd files
inside , the validate operation
will not be able to detect the problem.
Here is a sample command for validating a backup directory:
mysqlbackup -uroot --backup-dir=/logs/backupext validate
Here is a sample command for validating a backup image:
mysqlbackup -uroot --backup-image=/logs/fullimage.mi validate
The following is a sample command for validating an encrypted backup image and the output for the successful validation:
$ mysqlbackup –backup-image=/meb/backups/image.mbi --decrypt --key-file=/meb/enckeyfile validate
140219 11:22:44 mysqlbackup: INFO: Validating image ... /logs/img.bi
140219 11:22:44 mysqlbackup: INFO: Validate: [Dir]: meta
140219 11:22:45 mysqlbackup: INFO: Total files as specified in image: 44
mysqlbackup: INFO: datadir/tpch/tabnorm7.ibd Validated...
mysqlbackup: INFO: datadir/tpch/tabnorm8.ibd Validated...
mysqlbackup: INFO: datadir/tpch/tabnorm9.ibd Validated...
................
140219 11:22:45 mysqlbackup: INFO: Validate operation completed successfully.
140219 11:22:45 mysqlbackup: INFO: Backup Image validation successful.
mysqlbackup: INFO: Source Image Path = /logs/img.bi
mysqlbackup completed OK!This is a sample output for a checksum mismatch in the header:
mysqlbackup: ERROR: Checksum mismatch. Computed checksum: ### Checksum in image: ### mysqlbackup: ERROR: Problem verifying checksum of initial header of backup image. Image Path = /meb/backups/image.mbi mysqlbackup: ERROR: Backup image validation failed.
This is a sample output for an image containing corrupted
.ibd files:
mysqlbackup: ERROR: datadir/db2/bigtab1.ibd has corrupt page number : 64 page number from page header : 64 mysqlbackup: ERROR: datadir/db2/bigtab1.ibd is corrupt and has : 10 corrupt pages mysqlbackup: ERROR: datadir/db2/t1.ibd has corrupt page number : 4 page number from page header : 0 ....... mysqlbackup: ERROR: datadir/db2/t1.ibd is corrupt and has : 5 corrupt pages mysqlbackup: ERROR: datadir/ibdata1 has corrupt page number : 63 page number from page header : 63 mysqlbackup: ERROR: datadir/ibdata1 has corrupt page number : 7 page number from page header : 7 .......... mysqlbackup: ERROR: datadir/ibdata1 is corrupt and has : 10 corrupt pages mysqlbackup failed with errors!
This is a sample output for a successful validation for a compressed backup directory
mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm5.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm6.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm7.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm8.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm9.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabrowformat.ibz Validated... 140219 11:22:45 mysqlbackup: INFO: Validate backup directory operation completed successfully.
To simplify transfer and management of backup data, you can
keep each backup in a single file (the backup image). The
backup-to-image option performs a
backup directly to a single file, or the options here can pack
an existing backup into a single file or unpack a single-file
backup to a full backup directory structure. There are other
options for working with single-file backups, which are
explained below. For usage and examples, see
Section 3.3.5, “Making a Single-File Backup”.
mysqlbackup [STD-OPTIONS] [--backup-image=IMAGE] [--backup-dir=PATH] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]image-to-backup-dirmysqlbackup [STD-OPTIONS] [--backup-dir=PATH] [--backup-image=IMAGE] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]backup-dir-to-imagemysqlbackup [STD-OPTIONS] [--backup-image=IMAGE] [--src-entry=PATH] [MESSAGE-LOGGING-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]list-imagemysqlbackup [STD-OPTIONS] [--backup-image=IMAGE] [--backup-dir=PATH] [--src-entry=PATH] [--dst-entry=PATH] [MESSAGE-LOGGING-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]extractmysqlbackup [STD-OPTIONS] [SERVER-REPOSITORY-OPTIONS] [--backup-image=IMAGE] [--backup-dir=PATH] [MESSAGE-LOGGING-OPTIONS] [PARTIAL-BACKUP-RESTORE-OPTIONS] [PROGRESS-REPORT-OPTIONS] [ENCRYPTION-OPTIONS] [CLOUD-STORAGE-OPTIONS]copy-back-and-apply-log
image-to-backup-dir
Unpacks a single-file backup to a full backup directory structure. You specify the paths to both the image file and the destination directory in which to unpack. For usage and examples, see Section 3.3.5, “Making a Single-File Backup”.
backup-dir-to-image
Packs an existing backup into a single file. Specify a
--backup-image value of
- (standard output) to stream an
existing backup directory structure to a tape device or a
command that transfers the backup to another server. The
--backup-image parameter is either
- or an absolute path outside the
backup-dir directory. For usage and
examples, see Section 3.3.5, “Making a Single-File Backup”.
list-image
Display the contents of a single-file backup. Lists all
files and directories in the image. The
--src-entry=
can be used to list a specific file or directory. If the
name is a directory, all its files and subdirectories
inside the image are recursively listed. For usage and
examples, see
Section 3.3.5, “Making a Single-File Backup”.
name
The list-image operation
can be performed on a cloud backup only if the cloud
proxy supports range headers.
extract
Unpacks an individual file or directory from a single-file
backup. For troubleshooting or restoration operations that
do not require the full set of backup data. The resulting
file or directory goes in the current directory, or in
backup-dir if specified. All files and
directory contents in the image with absolute path names
are extracted into the same absolute path names on the
local system. For usage and examples, see
Section 3.3.5, “Making a Single-File Backup”.
The
--src-entry=
option can be used for selective extraction of a single
file or single directory in image. Specify the path as it
appears in the image.
path
The
--dst-entry=
option, along with
path--src-entry=
option can be used to extract a single file or single
directory into a user-specified file or directory
respectively. If the path--src-entry option
is used, but --dst-entry option is
omitted, then the selected file or directory is extracted
to the same path in the local file system.
The default destination for the extract is the current
working directory. It can be overridden by the
--backup-dir option. All the
files with relative pathnames in the image are extracted
to pathnames relative to the destination directory.
If the image contains some entries with absolute
pathnames, those entries are extracted to the same
absolute path names even if --backup-dir
option is specified. The
--dst-entry option must be
used to relocate an absolute pathname.
copy-back-and-apply-log
See description for
copy-back-and-apply-log in
Section 5.1.1.3, “Restore an Existing Backup”.
The standard options are options of a general nature, or options that are not classified under any other specific option group.
Here is a list of the standard options:
The following standard options also exist for the mysql command. Full descriptions for these options can be found in the MySQL reference manual, accessible through, e.g., Server Option and Variable Reference. These options must be specified ahead of any other mysqlbackup options, including the rest of the standard options:
--print-defaultsPrint the program argument list and exit.--no-defaultsDon't read default options from any option file.--defaults-file=Only read default options from the given file. It has to be the first option to be specified, if used.PATH--defaults-extra-file=Read this file after the global files are read.PATH--defaults-group-suffix=Also read option groups with the usual names and a suffix ofstrstr.
The following options are also common between
mysqlbackup and mysql,
and full descriptions for them can be found in the MySQL
reference manual, accessible through, e.g.,
Server Option and Variable Reference. However,
mysqlbackup does not accept any short forms for
these options as mysql does (for example,
you must use --help instead of
-h for mysqlbackup):
--helpDisplay help.--versionDisplay version information--verbosePrint more verbose information.--debugPrint debug information.
More standard options are available for mysqlbackup:
--forceForce operations such as overwrite files, create backup directory.--trace=levelTrace level of messages by mysqlbackup.
--force: By default, some of the operations
halt rather than overwrite any user data or log files when
told to write to existing files. --force
allows the overwriting of InnoDB data and log files during
the apply-log and
apply-incremental-backup operations and
allows the replacing of an image file during an
backup-to-image or
backup-dir-to-image option. For all other
operations, the --force option is
rejected with an error message.
| Command-Line Format | --trace=LEVEL | ||
| Permitted Values | Type | enumeration | |
| Default | 0 | ||
| Valid Values | 0 | ||
1 | |||
2 | |||
3 | |||
Trace level of mysqlbackup messages. The permissible levels, in the order of increasing fineness, are:
0 - INFO (information, warnings, errors)
1 - FINE (verbose option is enabled)
2 - FINER (debug option is enabled)
3 - FINEST (includes all low level outputs)
When mysqlbackup creates a backup, it sends SQL commands to MySQL server using a database connection. The general connection details are the same as described in Connecting to the MySQL Server in the MySQL Reference Manual.
As part of the mysqlbackup invocation,
specify the appropriate --user,
--password, --port, and/or
--socket options that are necessary to connect
to the MySQL server.
You can specify the following connection-specific options in the
[mysqlbackup] or [client]
sections of a MySQL configuration file, or through
mysqlbackup command-line options.
mysqlbackup reads your default configuration
files and then the my.cnf file specified on
the command line.
mysqlbackup reads only
--user, --password,
--port, and --socket
options from the [client] group, and
ignores any other connection options.
If you do not provide a value for the
--password, the command prompts for one
from the keyboard.
The --host option is allowed in the
configuration file for compatibility, but currently it has
no effect. The mysqlbackup command
always connects to the local server's IP address.
Options Common to mysqld ========================--login-path=name--port=port-num--protocol=tcp|socket|pipe|memory--pipe[ alias for --protocol=pipe ]--user=name[ short option: -u ]--host=hostname--socket=name--shared-memory-base-name=value[Windows only]--character-sets-dir=PATH--default-character-set=VALUE--secure-auth[ Don't connect to pre-4.1.1 server ]--password[=value] [ short option: -p ]--connect_timeout--ssl[ Enable SSL for connection ]--ssl-key=file_name--ssl-cert=file_name--ssl-ca=file_name--ssl-capath=directory_name--ssl-cipher=cipher_list--ssl-verify-server-certConnection Options Specific to mysqlbackup ==========================================--no-connection--connect-if-online
Most other connection parameters used by the mysql command are recognized, but silently ignored. Unknown connection parameters cause the mysqlbackup command to stop.
The following connections options are specific to mysqlbackup:
The --no-connection option supersedes the
other connection options and uses file-level operations to
perform the backup. When you use this option, you must
specify in the configuration file or on the command line
many options whose values are normally retrieved
automatically through the database connection.
This option also turns on the
--no-history-logging and
--no-locking options, which
might result in inconsistencies in non-InnoDB data if the
tables are modified during the backup operation. It might
also affect subsequent incremental backups; see the
description for the
--incremental-base option for
details.
By default, a database connection is used for backup
operations both during the initial stage to retrieve source
repository configuration, and to lock tables while copying
non-InnoDB data. This option allows
mysqlbackup to make connection attempts
in both phases, but continues even if the connection cannot
be established. If a connection cannot be established, the
processing is the same as with the
--no-connection
option. This option can be useful in emergency situations:
for example, when the database server goes down during the
backup operation.
These repository options specify various parameters related to the database server, from which the data is backed up or to which a backup is restored.
These options are used only with the following operations:
Backup creation operations:
backup,
backup-and-apply-log,
backup-to-image.
Restore operations: copy-back,
copy-back-and-apply-log.
When a database connection is available during a backup, the parameters describing the source repository are ignored, overridden by the corresponding values retrieved from the database connection.
For information about how these options are specified for the MySQL server, click the option names to see the descriptions in the MySQL Reference Manual.
datadir=PATH
This is the datadir value used by the
MySQL instance. The .frm files live
here inside subdirectories named after the databases inside
the instance.
When a database connection exists, the value is retrieved automatically and overrides any value you specify. This is a crucial parameter for both the MySQL server and MySQL Enterprise Backup.
innodb_data_home_dir=PATH
Specifies the directory where InnoDB data files live.
Usually the same as
datadir, but can be
different.
This parameter, together with
innodb_data_file_path=SIZE,
determines where the InnoDB data files such as
ibdata1, ibdata2,
and so on, are situated within the MySQL server.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection.
Its value is derived as follows:
If innodb_data_home_dir is not
specified, it inherits the value of
datadir.
If innodb_data_home_dir is a relative
path, that path is located relative to (that is,
underneath) the datadir value.
An innodb_data_home_dir of
"" refers to the
/ root directory.
If innodb_data_home_dir is an absolute
path, its value is used as-is.
innodb_data_file_path=VALUE
Specifies InnoDB data file names and sizes. Examples:
ibdata1:32M;ibdata2:32M:autoextend /abs/path/ibdata1:32M:autoextend innodb-dir/ibdata1:32M:autoextend
When a database connection exists, the value is retrieved automatically and overrides any value you specify.
This parameter together with innodb_data_home_dir determines
where the InnoDB data files (such as
ibdata1, ibdata2,
and so on) live in server repository.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection. If no database connection is available, you must specify it.
Whether the initial filename begins with a
/ character or not, the files are located
relative to the innodb_data_home_dir value.
innodb_log_group_home_dir=PATH
Specifies where InnoDB logs live within the server
repository. Usually the same as datadir,
but can be different.
Its value is derived as follows:
If innodb_log_group_home_dir is not
specified, it inherits the value of
datadir.
If innodb_log_group_home_dir is a
relative path, that path is located relative to (that
is, underneath) the datadir value.
If innodb_log_group_home_dir is an
absolute path, its value is used as-is.
Specifies the number of InnoDB log files before being rotated.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection. If no database connection is available, you must specify it.
When a database connection exists, the value is retrieved automatically and overrides any value you specify.
innodb_log_file_size=SIZE
Specifies maximum single InnoDB log file size before switching to next log file. Example: 20M.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection. If no database connection is available, you must specify it.
When a database connection exists, the value is retrieved automatically and overrides any value you specify.
innodb_page_size=SIZE
Specifies the page size for all InnoDB tablespaces.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection. If no database connection is available, you must specify it.
When a database connection exists, the value is retrieved automatically and overrides any value you specify.
innodb_checksum_algorithm=NAME
Specifies the name of the checksum algorithm used for
validating InnoDB tablespaces. Default is
innodb.
Typically, you do not need to specify this option, because its value is retrieved automatically using the database connection. If no database connection is available, you must specify it.
When a database connection exists, the value is retrieved automatically and overrides any value you specify.
These options specify various parameters related to the layout of the backup directory.
The --backup-dir option is the only one from
this group that you typically specify. Values for all the
backup_innodb_* options can be derived
automatically from the corresponding configuration options
without the backup_ prefix (see descriptions
for individual options below). Those options need to be
specified only if, during a backup, the user wants to specify
particular values for those options that are to be used during
restorations of the backup. Values specified by
backup_innodb_* options are stored in the
backup_my.cnf file, to be used during
future restorations.
When a database connection is available during a backup, those
backup_innodb_* options are ignored, with
their values overridden by the corresponding values retrieved
from the database connection. .
These options are used only with the following operations:
Backup creation operations:
backup,
backup-and-apply-log,
backup-to-image.
Restore operations: copy-back,
copy-back-and-apply-log.
The following parameters describe the layout of files in the backup directory:
Same as
--backup-dir.
The directory under which to store the backup data. This is
a crucial parameter required for most kinds of backup
operations. It cannot be a subdirectory of the directory
specified by
--datadir. An
additional level of subdirectory is created when the
--with-timestamp option is also specified.
Also, when restoring a single-file backup with
copy-back-and-apply-log,
--backup-dir is used for supplying the
location of a folder that will be used for storing temporary
files produced during the restoration process.
backup_innodb_data_home_dir=PATH
Specifies the directory where backup InnoDB data files live.
Usually same as backup-dir, but can be
different.
This parameter together with
backup_innodb_data_file_path determines
where the InnoDB data files (such as
ibdata1, ibdata2,
...) are stored inside the backup directory structure.
This parameter is applicable only for backup operations, not restore.
For the backup operations (such as backup,
backup-and-apply-log,
backup-to-image), the value of the backup
destination directory is derived as follows:
If backup_innodb_data_home_dir is not
specified, it inherits the value of
backup-dir.
If backup_innodb_data_home_dir is a
relative path, that path is located relative to (that
is, underneath) the backup-dir value.
An backup_innodb_data_home_dir of
"" refers to the
/ root directory.
If backup_innodb_data_home_dir is an
absolute path, its value is used as-is.
To make it easy to relocate the backup directory and avoid
editing the backup-my.cnf file, the
backup operation writes this value into
backup-my.cnf only if it is different
than the backup-dir value, and using a
relative path if possible.
For backup-to-image operations, the final
value of the backup_innodb_data_home_dir
option must be a relative path, so that the single-file
backup is machine-independent.
backup_innodb_data_file_path=VALUE
Specifies InnoDB data file names and sizes. Examples:
ibdata1:32M;ibdata2:32M:autoextend /abs/path/ibdata1:32M:autoextend innodb-dir/ibdata1:32M:autoextend
This parameter together with
backup_innodb_data_home_dir determines
where the InnoDB data files (such as
ibdata1, ibdata2,
...) live in the backup repository.
Within the backup directory, any data files specified with
relative paths are located relative to the
backup_dir path. Any data files specified
with absolute paths are placed inside the
backup_innodb_data_home directory.
When the parameter is not specified, it inherits the value
from the value of the innodb_data_file_path
option. If both source and destination attempt to use an
absolute path that resolve to the same files, the backup is
cancelled.
To specify absolute paths for InnoDB datafiles in backup,
you must also set the
backup_innodb_data_home option to
"".
backup_innodb_log_group_home_dir=PATH
Specifies where backup InnoDB logs live. Usually the same as
backup-dir, but can be different.
The names of the log files are fixed and not reconfigurable.
This parameter is applicable only for backup operations (not restore).
The backup operation uses this value and writes it as
innodb_log_group_home_dir=
in valuebackup-my.cnf.
For copy-back and
apply-log operations,
innodb_log_group_home_dir in
backup-my.cnf is treated in a way that
is compatible with how it was created.
backup_innodb_log_files_in_group=N
Specifies the number of InnoDB log files in backup before being rotated. Example: 5.
Usually same as innodb_log_files_in_group,
but can be different.
The value for this parameter is derived as:
Specified
backup_innodb_log_files_in_group
value from command line or configuration file.
Else innodb_log_files_in_group value
from the database connection, if available.
Else the innodb_log_files_in_group
value from the command line or configuration file.
backup_innodb_log_file_size=SIZE
Specifies maximum single InnoDB log file size in backup before switching to next log file. Example: 20M.
Usually the same as innodb_log_file_size,
but can be different.
The value for this parameter is derived as:
Specified backup_innodb_log_file_size
value from command line or configuration file.
Else innodb_log_file_size value from
database connection, if available.
Else specified innodb_log_file_size
value from command line or configuration file.
The page size for all InnoDB tablespaces in a MySQL instance. The page size must be the same value as in MySQL instance. By default, it assumes the innodb page size in server.
backup_innodb_checksum_algorithm=NAME
The name of the checksum algorithm used for validating InnoDB tablespaces. Default is 'innodb'.
backup_innodb_undo_directory=PATH
The relative or absolute directory path where InnoDB creates separate tablespaces for the undo logs. Typically used to place those logs on a different storage device.
backup_innodb_undo_logs=NUMBER
Number of rollback segments in the system tablespace that InnoDB uses within a transaction. This setting is appropriate for tuning performance if you observe mutex contention related to the undo logs.
backup_innodb_undo_tablespaces=NUMBER
The number of tablespace files that the undo logs are divided between, when you use a non-zero innodb_undo_logs setting. By default, all the undo logs are part of the system tablespace and the system tablespace will always contain one undo tablespace in addition to those configured by innodb_undo_tablespaces.
Creates a subdirectory underneath the backup directory, with a name formed from the timestamp of the backup operation. Useful to maintain a single backup directory containing many backup snapshots.
Default: no timestamped subdirectory is created. To reuse
the same backup directory for a new backup, either remove
the previous backup files manually or specify the
--force option to overwrite
them.
These options control the generation of metadata about backups.
Some metadata is stored in the backup directory, other metadata
is stored in tables within the mysql database
of the backed-up instance.
--no-history-logging
Turns off the recording of backup progress and history in logging tables inside the backed-up database. See Section 11.3, “Using the MySQL Enterprise Backup Logs” for details about these tables.
Default: history logging is enabled. When
--no-connection is specified, history
logging is automatically disabled. When
--connect-if-online is specified, history
logging only works if a database connection is successfully
established during the backup.
--comments=STRING
| Command-Line Format | --comments=STRING | ||
| Permitted Values | Type | string | |
Specifies a comment string that describes or identifies the
backup. Surround multi-word comments with appropriate
quotation marks. The string is saved in a file
meta/comments.txt in the backup. For
example: --comments="Backup of HR data on
2010/12/10".
--comments-file=PATH
| Command-Line Format | --comments-file=PATH | ||
| Permitted Values | Type | file name | |
Specifies path to a file containing comments describing the
backup. This file is saved as
meta/comments.txt in the backup. For
example:
--comments-file=/path/to/comments.txt.
This option overrides the
--comments option if both are
specified.
For an overview on backup compression, see Section 3.3.3, “Making a Compressed Backup”.
--compress
Create backup in compressed format. For a regular backup,
only the InnoDB data files are compressed, and they bear the
.ibz extension after the compression.
Similarly, for a single-image backup, only the InnoDB data
files inside the backup image are compressed.
Default: compression is disabled.
--compress-method=ALGORITHM
| Command-Line Format | --compress-method=ALGORITHM | ||
| Permitted Values | Type | enumeration | |
| Default | lz4 | ||
| Valid Values | zlib | ||
lz4 | |||
lzma | |||
Specifies the compression algorithm. The supported arguments for the option and the algorithms they represent are:
lz4: LZ4 r109. Out of the three
algorithms that are supported, this is the most
efficient one, typically taking the shortest backup
and restore times with the lowest CPU cost. See
lz4—Extremely Fast Compression algorithm
for more details, including a comparison with other
compression algorithms.
lzma: LZMA 9.20. Out of the three
supported algorithms, this typically provides the
highest compression ratio; but it is also far more
expensive in terms of CPU cost than the other two
options. Thus we do not recommend this for active
systems, but only for off-hour or inactive databases,
or where I/O rates are extremely low.
zlib: ZLIB v1.2.3. This is in
between the other two supported algorithms in terms of
both speed and compression ratio. ZLIB was the only
compression algorithm available for MySQL Enterprise Backup versions
prior to 3.10.
Default: lz4. Explicitly specifying a value for the option
through a configuration file or command line automatically
enables the --compress option.
--compress-level=LEVEL
| Command-Line Format | --compress-level=LEVEL | ||
| Permitted Values | Type | numeric | |
| Default | 1 | ||
| Min Value | 0 | ||
| Max Value | 9 | ||
Specifies the level of compression, ranging from
“0” to “9”: “0
”disables compression; “1” is fastest
compression, and “9” is highest (and slowest)
compression. The option is only meaningful for compression
using the ZLIB or LZMA algorithm; it is ignored when any
other algorithms are selected by the
--compress-method option.
Default: 1 (lowest and fastest compression). Explicitly
specifying a non-zero value through a configuration file or
command line automatically enables the
--compress option.
--uncompress
When used with the apply-log or
copy-back-and-apply-log
operation, uncompresses the compressed backup before
applying the InnoDB log.
For an overview of incremental backups and usage information about these options, see Section 3.3.2, “Making an Incremental Backup”.
To take an incremental backup, specify the
--incremental or
--incremental-with-redo-log-only,
along with the
--incremental-backup-dir. All InnoDB
data modified after the specified
LSN is copied in the incremental
backup. Depending on the choice of
--incremental or
--incremental-with-redo-log-only other options
are required or recommended.
--incremental
Specifies that the associated
backup or
backup-to-image operation is
incremental.
Also requires either the
--incremental-base option, or
the combination of the
--start-lsn and
--incremental-backup-dir
options.
The incremental aspect applies only to InnoDB tables. By
default, all non-InnoDB and .frm files
are also included in incremental backup. To exclude
non-InnoDB data in an incremental backup, use the
--only-innodb option.
--incremental-with-redo-log-only
Specifies an alternative form of
incremental
backup for a backup or
backup-to-image operation. Also
requires either the
--incremental-base option, or
the combination of the
--start-lsn and
--incremental-backup-dir
options.
The incremental backup performed by this option has
different performance characteristics and operational
limitations than with the
--incremental option:
The changes to InnoDB tables are determined based on the
contents of the InnoDB
redo log. Since the
redo log files have a fixed size that you know in
advance, it can require less I/O to read the changes
from them than to scan the InnoDB tablespace files to
locate the changed pages, depending on the size of your
database, amount of DML activity, and size of the redo
log files.
Since the redo log files act as a circular buffer, with
records of older changes being overwritten as new
DML operations take
place, you must take new incremental backups on a
predictable schedule that depends on the size of the log
files and the amount of redo data generated for your
workload. Otherwise, the redo log might not reach back
far enough to record all the changes since the previous
incremental backup. In this case, the
mysqlbackup command quickly
determines it cannot proceed and returns an error. Your
backup script can catch the error and do an incremental
backup with the
--incremental option
instead. options.
For example:
To calculate the size of the redo log, issue the
command
SHOW
VARIABLES LIKE 'innodb_log_file%', and
based on the output, multiply the
innodb_log_file_size
setting by
innodb_log_files_in_group.
To compute redo log size at the physical level, look
in the datadir directory of the
MySQL instance and sum the sizes of the files
matching the pattern
ib_logfile*.
The InnoDB LSN value
corresponds to the number of bytes written to the
redo log. To check the LSN at some point in time,
issue the command
SHOW
ENGINE INNODB STATUS and look under the
LOG heading. While planning your
backup strategy, record the LSN values periodically
and subtract the earlier value from the current one
to calculate how much redo data is generated each
hour, day, and so on.
Prior to MySQL 5.5, it was common practice to keep the redo logs fairly small to avoid long startup times when the MySQL server was killed rather than shut down normally. In MySQL 5.5 and higher, the performance of crash recovery is significantly improved, as described in Optimizing InnoDB Configuration Variables. With those releases, you can make your redo log files bigger if that helps your backup strategy and your database workload.
This type of incremental backup is not so forgiving of
too-low --start-lsn values
as the standard --incremental option.
For example, you cannot make a full backup and then make
a series of
--incremental-with-redo-log-only
backups all using the same --start-lsn
value. Make sure to specify the precise end LSN of the
previous backup as the start LSN of the next incremental
backup; do not use arbitrary values.
To ensure the LSN values match up exactly between
successive incremental backups using this option,
Oracle recommends always using the
--incremental-base option
when you use the
--incremental-with-redo-log-only
option.
To judge whether this type of incremental backup is practical and efficient for a particular MySQL instance:
Measure how fast the data changes within the InnoDB redo log files. Check the LSN periodically to see how much redo data accumulates over the course of some number of hours or days.
Compare the rate of redo log accumulation with the size of the redo log files. Use this ratio to see how often to take an incremental backup, to avoid the likelihood of the backup failing due to historical data not available in the redo log. For example, if you are producing 1GB of redo log data per day, and the combined size of your redo log files is 7GB, you would schedule incremental backups more frequently than once a week. You might perform incremental backups every day or two, to avoid a potential issue if a sudden flurry of updates produced more redo than usual.
Benchmark incremental backup times using both the
--incremental and
--incremental-with-redo-log-only
options, to confirm if the redo log backup technique
performs faster and with less overhead than the
traditional incremental backup method. The result
could depend on the size of your data, amount of DML
activity, and size of your redo log files; do your
testing on a server with a realistic data volume and
running a realistic workload. For example, if you
have huge redo log files, reading them in the course
of an incremental backup could take as long as
reading the InnoDB data files using the traditional
incremental technique. Conversely, if your data
volume is large, reading all the data files to find
the few changed pages could be less efficient than
processing the much smaller redo log files.
As with the --incremental
option, the incremental aspect applies only to InnoDB
tables. By default, all non-InnoDB and
.frm files are also included in
incremental backup. To exclude non-InnoDB data in an
incremental backup, use the
--only-innodb option.
--incremental-base=mode:argument
| Command-Line Format | --incremental-base=mode:argument | ||
| Permitted Values | Type | string | |
With this option, the mysqlbackup
retrieves the information needed to perform incremental
backups from the metadata inside the backup directory rather
than from the --start-lsn
option. It saves you from having to specify an
ever-changing, unpredictable
LSN value when doing a
succession of incremental backups. Instead, you specify a
way to locate the previous backup directory through the
combination of mode and
argument in the option syntax.
The alternatives are:
dir:
directory_path
You specify the prefix dir: followed
by a directory path. The path argument points to the
root directory where the data from the previous backup
is stored. With the first incremental backup, you
specify the directory holding the full backup; with the
second incremental backup, you specify the directory
holding the first incremental backup, and so on.
history:last_backup
You specify the prefix history:
followed by last_backup, the only
valid argument for this mode. This makes
mysqlbackup query the
end_lsn value from the last
successful
non-TTS
backup as recorded in the
backup_history table of the server
instance that is being backed up.
If the last full or partial backup made was a
TTS
backup, mysqlbackup skips it, and
keeps searching the backup history until it finds the
last
non-TTS
backup and then returns its
end_lsn value.
Do not use the history: mode if the
previous backup was a full backup taken with the
--no-connection option,
which always turns off the recording of backup history
and might cause errors in a subsequent incremental
backup using this mode of the
--incremental-base option.
--start-lsn=LSN
| Command-Line Format | --start-lsn=LSN | ||
| Permitted Values | Type | numeric | |
In an incremental
backup, specifies the highest
LSN value included in a
previous backup. You can get this value from the output of
the previous backup operation, or from the
backup_history
table's end_lsn column for the previous
backup operation. Always used in combination with the
--incremental option; not needed
when you use the --incremental-base option;
not recommended when you use the
--incremental-with-redo-log-only
mechanism for incremental backups.
--incremental-backup-dir=PATH
| Command-Line Format | --incremental-backup-dir=PATH | ||
| Permitted Values | Type | directory name | |
Specifies the location under which to store data from an
incremental backup. This is the same location you specify
with --incremental-base if you
use that option for a subsequent incremental backup.
Example 5.4 Incremental Backup
These examples show typical combinations of options used for incremental backups.
mysqlbackup --incremental \ --incremental-backup-dir=/var/mysql/backup/latest \ --incremental-base=dir:/var/mysql/backup/previous \ ... backup mysqlbackup --incremental-with-redo-log-only \ --incremental-backup-dir=/var/mysql/backup/latest \ --incremental-base=dir:/var/mysql/backup/previous \ ... backup mysqlbackup --incremental --start-lsn=12345 \ --incremental-backup-dir=/var/mysql/backup/inc \ ... backup mysqlbackup --incremental-with-redo-log-only --start-lsn=12345 \ --incremental-backup-dir=/var/mysql/backup/inc \ ... backup
Since MySQL Enterprise Backup 3.10, the two options
--include-tables and
--exclude-tables have been
introduced. These were intended for replacing the older
options of --include,
--databases,
--databases-list-file, and
--only-innodb-with-frm,
which are incompatible with the new options and will be
deprecated in future releases. For references purpose, we have
included information on the older options at the end of this
section in
Legacy Partial
Backup Options.
To select specific data to be backed up or restored, use the partial backup and restore options described in this section.
For an overview of partial backup and usage information on the following options for partial backup, see Section 3.3.4, “Making a Partial Backup”.
--include-tables=REGEXP
| Command-Line Format | --include-tables=REGEXP | ||
| Permitted Values | Type | string | |
Include for backup or restoration only those tables (both
innodb and non-innodb) whose fully qualified names (in the
form of
)
match the regular expression
db_name.table_nameREGEXP. The regular expression
syntax used is the extended form specified in the POSIX
1003.2 standard. For example,
--include-tables=^mydb\.t[12]$ matches
the tables t1 and t2
in the database mydb. On Unix-like
systems, quote the regular expression appropriately to
prevent interpretation of shell meta-characters. Some
limitations apply when using the option to select database
names or file names that contain special characters (spaces,
dashes, periods, etc.); see
this
description in Appendix A, MySQL Enterprise Backup Limitations for details.
mysqlbackup throws an error when the
option is used without a regular expression being supplied
with it.
While the option can be used for different kinds of backups,
selective restore is only supported for backups created
using
transportable
tablespaces (TTS) (that is, backups created with the
--use-tts
option).
The option cannot be used together with the legacy
--include,
--databases,
--databases-list-file, or
--only-innodb-with-frm option.
When used together with the
--exclude-tables option,
--include-tables is applied
first, meaning mysqlbackup first selects
all tables specified by
--include-tables and then
excludes from the set those tables specified by
--exclude-tables.
| Command-Line Format | --exclude-tables=REGEXP | ||
| Permitted Values | Type | string | |
Exclude for backup or restoration all tables (both innodb
and non-innodb) whose fully qualified names (in the form of
)
match the regular expression
db_name.table_nameREGEXP. The regular expression
syntax is the extended form specified in the POSIX 1003.2
standard. For example,
--exclude-tables=^mydb\.t[12]$ matches
the tables t1 and t2
in the database mydb. On Unix-like
systems, quote the regular expression appropriately to
prevent interpretation of shell meta-characters. Some
limitations apply when using the option to select database
names or file names that contain special characters (spaces,
dashes, periods, etc.); see
this
description in Appendix A, MySQL Enterprise Backup Limitations for details.
mysqlbackup throws an error when the
option is used without a regular expression being supplied
with it.
While the option can be used for different kinds of backups,
selective restore is only supported for backups created
using
transportable
tablespaces (TTS) (that is, backups created with the
--use-tts
option).
The option cannot be used together with the
--include,
--databases,
--databases-list-file, or
--only-innodb-with-frm option.
When used together with the
--include-tables option,
--include-tables is applied
first, meaning mysqlbackup first select
all tables specified by
--include-tables, and then
exclude from the set those tables specified by
--exclude-tables for backup.
For back up only. By default, all files in the database
subdirectories under the data directory of the server are
included in the backup (see
Section 1.4, “Files that Are Backed Up” for details). If the
--only-known-file-types option is
specified, mysqlbackup only backs up
those types of files that are data files for MySQL or its
built-in storage engines, which have the following
extensions:
.ARM: Archive storage engine
metadata
.ARZ: Archive storage engine data
.CSM: CSV storage engine data
.CSV: CSV storage engine data
.frm: table definitions
.ibd: InnoDB tablespace created
using the file-per-table mode
.MRG: Merge storage engine
references to other tables
.MYD: MyISAM data
.MYI: MyISAM indexes
.opt: database configuration
information
.par: partition definitions
.TRG: trigger parameters
.TRN: trigger namespace information
--only-innodb
For back up only. Back up only InnoDB data and log files. All files created by other storage engines are excluded. Typically used when no connection to mysqld is allowed or when there is no need to copy MyISAM.
The option is not compatible with the
--slave-info option.
Default: backups include files from all storage engines.
--use-tts[={with-minimum-locking|with-full-locking}]
| Command-Line Format | --use-tts[={with-minimum-locking|with-full-locking}] | ||
| Permitted Values | Type | enumeration | |
| Default | with-minimum-locking | ||
| Valid Values | with-minimum-locking | ||
with-full-locking | |||
Enable selective backup of InnoDB tables using
transportable
tablespaces (TTS). This is to be used in conjunction
with the --include-tables and
--exclude-tables options to
select the InnoDB tables to be backed up by regular
expressions. Using
TTS for
backups offers the following advantages:
Backups can be restored to a different server
The system tablespace is not backed up, saving disk space and I/O resources
Data consistency of the tables is managed by MySQL Enterprise Backup
However, the option has the following limitations:
Supports only MySQL version 5.6 and after (as earlier versions of MySQL do not support TTS)
Can only backup tables that are stored in their own individual tablespaces (i.e., tables created with the innodb_file_per_table option enabled)
Cannot back up partitioned tables
Cannot be used for incremental backups
Does not include the binary log or the relay log in the backup
There are two possible values for the option:
with-minimum-locking: Hot copies of
the selected tables are backed up, and the tables are
then locked in read-only mode while the
redo log (with
only the portion containing the relevant changes made
after the hot backup) is being included in the backup.
Any tables created during the locking phase are
ignored.
with-full-locking: The selected
tables are locked in read-only mode while they are
being backed up. The
redo log is not
included in the backup. Any tables created during the
locking phase are ignored.
Due to a known issue, when creating a backup using TTS for a server containing tables with a mix of the Antelope and Barracuda file formats, do NOT apply full locking on the tables.
Default: back up with minimum locking
To use the --use-tts option,
extra privileges are required of the user through which
mysqlbackup connects to the server; see
Section 3.1.2, “Grant MySQL Privileges to Backup Administrator” for details.
There are some special requirements for restoring backups
created with the --use-tts
option; see Restoring Backups Created with the --use-tts Option
for details.
Information in this subsection is only for using the legacy
options of --include,
--databases,
--databases-list-file,
and --only-innodb-with-frm, which
will be deprecated in the upcoming issues. For creating
partial backups, it is strongly recommended that the new
options of --include-tables and
--exclude-tables be used instead.
Note that you cannot combine the legacy and the new
partial-backup options in a single command.
Besides the legacy options, some other options are also discussed below, but the information is only for using the options together with the legacy partial-backup options.
For an overview of partial backups and usage information about these legacy options, see Making a Partial Backup with the Legacy Options.
--include=REGEXP
This option is for filtering InnoDB tables for backup. The
InnoDB tables' fully qualified names are checked against the
regular expression specified by the option. If the REGEXP
matches
,
the table is included. The regular expression syntax used is
the extended form specified in the POSIX 1003.2 standard.
For example, db_name.table_name--include=mydb\.t[12]
matches the tables t1 and
t2 in the database
mydb. mysqlbackup
throws an error when the option is used without a regular
expression being supplied with it.
This option only applies to InnoDB tables created with the
MySQL option
innodb_file_per_table enabled
(which is the default setting for MySQL 5.6 and after), in
which case the tables are in separate files that can be
included or excluded from the backup. All tables in the
InnoDB system tablespace are always backed up.
When no InnoDB table names match the specified regular expression, an error is thrown with a message indicating there are no matches.
Default: Backs up all InnoDB tables.
This option does not filter non-InnoDB tables, for which
options like --databases and
--databases-list-file can be
used.
This option does not filter the .frm
files associated with InnoDB tables, meaning that
regardless of the option’s value, all the
.frm files for all InnoDB tables are
always backed up unless they are excluded by other
options. Those .frm files for InnoDB
tables that are not backed up should be deleted before the
database backup is restored. See
Making a Partial Backup with the Legacy Options for details.
--databases=LIST
Specifies the list of non-InnoDB tables to back up. The argument specifies a space-separated list of database or table names of the following form:
"db_name[.table_name]db_name1[.table_name1] ...".
If the specified values do not match any database or table, then no non-InnoDB data files are backed up. See Making a Partial Backup with the Legacy Options for details.
By default, all non-InnoDB tables from all databases are backed up.
The option has no filtering effects on the InnoDB data
files (.ibd files) for the databases
or tables it specifies. To filter InnoDB data files, use
the --include
option instead.
--databases-list-file=PATH
Specifies the pathname of a file that lists the non-InnoDB
tables to be backed up. The file contains entries for
databases or fully qualified table names separated by
newline or space. The format of the entries is the same as
for the --databases option:
db_name[.table_name]db_name1[.table_name1] ...
Remove any whitespaces surrounding the database or table
names, as the whitespaces are not removed automatically.
Begin a line with the # character to
include a comment. No regular expressions are allowed.
If the specified entries do not match any database or table, then no non-InnoDB data files are backed up.
The option has no filtering effects on the InnoDB data
files (.ibd files) for the databases
or tables it specifies. To filter InnoDB data files, use
the --include
option instead.
--only-innodb-with-frm[={all|related}]
Back up only InnoDB data, log files, and the
.frm files associated with the InnoDB
tables.
--only-innodb-with-frm=all includes
the .frm files for all InnoDB
tables in the backup.
--only-innodb-with-frm=related, in
combination with the
--include option, copies
only the .frm files for the
tables that are included in the partial backup.
--only-innodb-with-frm with no
argument is the same as
--only-innodb-with-frm=related.
For incremental backups, even only changed
.ibd files are backed up,
.frm files associated with
all specified InnoDB tables are
included.
This option saves you having to script the backup step for
InnoDB .frm files, which you would
normally do while the server is put into a read-only state
by a FLUSH TABLES WITH READ LOCK
statement. The .frm files are copied
without putting the server into a read-only state, so that
the backup operation is a true
hot backup and does
not interrupt database processing. You must ensure that no
ALTER TABLE or other DDL
statements change .frm files for InnoDB
tables while the backup is in progress. If the
mysqlbackup command detects changes to
any relevant .frm files during the
backup operation, it halts with an error. If it is not
practical to forbid DDL on InnoDB tables during the backup
operation, use the --only-innodb option
instead and use the traditional method of copying the
.frm files while the server is locked.
All files created by other storage engines are excluded. Typically used when no connection to mysqld is allowed or when there is no need to copy MyISAM files, for example, when you are sure there are no DDL changes during the backup. See Making a Partial Backup with the Legacy Options for instructions and examples.
The option is not compatible with the
--slave-info option.
Default: backups include files from all storage engines.
--use-tts[={with-minimum-locking|with-full-locking}]
Enable selective backup of InnoDB tables using
transportable
tablespaces (TTS). This is to be used in conjunction
with the --include
option, which selects the InnoDB tables to be backed up by a
regular expression. Using
TTS for
backups offers the following advantages:
Backups can be restored to a different server
The system tablespace is not backed up, saving disk space and I/O resources
Data consistency of the tables is managed by MySQL Enterprise Backup
However, the option has the following limitations:
Supports only MySQL version 5.6 and after (as earlier versions of MySQL do not support TTS)
Can only backup tables that are stored in their own individual tablespaces (i.e., tables created with the innodb_file_per_table option enabled)
Cannot back up partitioned tables
Cannot restore tables selectively from the backup
Cannot be used for incremental backups
There are two possible values for the option:
with-minimum-locking: Hot copies of
the selected tables are backed up, and the tables are
then locked in read-only mode while the
redo
log (with only the portion containing the
relevant changes made after the hot backup) is being
included in the backup. Any tables created during the
locking phase are ignored.
with-full-locking: The selected
tables are locked in read-only mode while they are
being backed up. The
redo log is not
included in the backup. Any tables created during the
locking phase are ignored.
Default: back up with minimum locking
There are some special requirements for restoring backups
created with the --use-tts
option; see the
explanations in
Section 4.2, “Performing a Restore Operation” for details.
These options are associated with single-file backups. You use
them in combination with the mysqlbackup
subcommands backup-to-image,
image-to-backup-dir,
backup-dir-to-image,
list-image, and
extract that pack or unpack
single-image backups. For usage information, see
Section 3.3.5, “Making a Single-File Backup”.
--backup-image=IMAGE
| Command-Line Format | --backup-image=IMAGE | ||
| Permitted Values | Type | file name | |
Specify the path name of the file used for a single-file backup. By default, the single-file backup is streamed to standard output, so that you can pipe it directly to other commands such as tape backup or ssh-related network commands.
You can optionally prefix the image name with
file: to signify file I/O (the default).
For tape backups, prefix the image name
withsbt:. See
Section 3.3.5.2, “Backing Up to Tape” for details about tape
backups.
--src-entry=PATH
| Command-Line Format | --src-entry=PATH | ||
| Permitted Values | Type | path name | |
Identifies a file or directory to extract from a single-file
backup. This option is used with the
extract command. If the argument
is a directory, all its files and subdirectory contents are
extracted. No pattern matching expression is allowed for the
argument. Optionally, you can also specify the
--dst-entry option to extract
the file or directory in a location different from its
original path name.
For example: src-entry=meta/comments.txt
extracts only one file, comments.txt,
while src-entry=meta extracts the entire
directory tree for the meta
subdirectory.
Default: All entries are extracted.
--dst-entry=PATH
| Command-Line Format | --dst-entry=PATH | ||
| Permitted Values | Type | path name | |
Used with single-file backups to extract a single file or
directory to a user-specified path. Use of this option
requires specifying the
--src-entry option. This option
specifies the destination path for the selected entry in
backup image corresponding to entry specified by
-src-entry=
option. The entry could point to a single file or single
directory. For example, to retrieve the comments file from a
backup image and store it as
PATH/tmp/my-comments.txt, use a command
like the following:
mysqlbackup --src-entry=meta/comments.txt \ --dst-entry=/tmp/my-comments.txt \ --backup-image=/var/myimage.bki extract
Similarly, to extract all the contents of the
meta directory in a single-file backup
as /data/my-meta, use a command like
the following:
mysqlbackup --src-entry=meta \ --dst-entry=/data/my-meta \ --backup-image=/var/myimage.bki extract
The specified path is a simple path name without any wildcard expansion or regular expressions.
Default: By default, original pathnames are used to create files in the local file system.
--sbt-database-name=NAME
| Command-Line Format | --sbt-database-name=NAME | ||
| Permitted Values | Type | string | |
| Default | MySQL | ||
For tape backups, this option can be used as a hint to the Media Management Software (MMS) for the selection of media and policies. This name has nothing to do with MySQL database names. It is a term used by the MMS. See Section 3.3.5.2, “Backing Up to Tape” for usage details.
--sbt-lib-path=PATH
| Command-Line Format | --sbt-lib-path=PATH | ||
| Permitted Values | Type | file name | |
Path name of the SBT library used by software that manages
tape backups. If this is not specified, operating
system-specific search methods are used to locate
libobk.so (UNIX) or
orasbt.dll (Windows). See
Section 3.3.5.2, “Backing Up to Tape” for usage details.
--sbt-environment=VAR=value,...
| Command-Line Format | --sbt-environment=VAR1=value1[,VAR2=value2[,...]] SBT API provider) | ||
| Permitted Values | Type | string | |
Passes product-specific environment variables to Oracle Secure Backup or another SBT-compliant backup management product, as an alternative to setting and unsetting environment variables before and after each mysqlbackup invocation.
The parameter to this option is a comma-separated list of
key-value pairs, using syntax similar to that of the RMAN
tool for the Oracle Database. For example,
--sbt-environment=VAR1=val1,VAR2=val2,VAR3=val3.
Consult the documentation for your backup management product
to see which of its features can be controlled through
environment variables. For example, the Oracle Secure Backup
product
defines
environment variables such as
OB_MEDIA_FAMILY,
OB_DEVICE, and
OB_RESOURCE_WAIT_TIME. You might set such
variables with the mysqlbackup by
specifying an option such as
--sbt-environment="OB_MEDIA_FAMILY=my_mf,OB_DEVICE=my_tape".
If the argument string contains any whitespace or special
characters recognized by the command shell, enclose the
entire argument string in quotation marks. To escape an
equals sign or comma, use the \
character. For example,
--sbt-environment="VAR1=multiple
words,VAR2=<angle_brackets>,VAR3=2+2\=4".
--disable-manifest
Disable generation of
manifest files for a
backup operation, which are
backup_create.xml and
backup_content.xml present in the
meta subdirectory.
These options limit the resources used by the backup process, in order to minimize backup overhead for busy or huge databases, or specify behaviors of the process when encountering resource issues.
--number-of-buffers=
num_buffers
| Command-Line Format | --number-of-buffers=NUMBER | ||
| Permitted Values | Type | numeric | |
| Default | 14 | ||
| Min Value | 1 | ||
Specifies the number of buffers, each 16MB in size, to use during multithreaded options.
Use a high number for CPU-intensive processing such as backup, particularly when using compression. Use a low number for disk-intensive processing such as restoring a backup. This value should be at least as high as the number of read threads or write threads, depending on the type of operation.
Default: currently 14.
For compression or incremental backup operations, the buffer size is slightly more than 16MB to accommodate the headers.
One additional buffer is used for single-file incremental backup and single-file compressed backup.
Compressed backup, compressed single-file backup, and uncompress apply-log operations require one additional buffer for each process thread.
If you change the number of read, write, and processing threads, you can experiment with changing this value so that it is slightly larger than the total number of threads specified by those other options. See Section 7.1, “Optimizing Backup Performance” and Section 7.2, “Optimizing Restore Performance” for additional advice about recommended combinations of values for this and other performance-related options for various hardware configurations, such as RAID or non-RAID storage devices.
--read-threads=
num_threads
| Command-Line Format | --read-threads=NUMBER | ||
| Permitted Values | Type | numeric | |
| Default | 1 | ||
| Min Value | 1 | ||
| Max Value | 15 | ||
Specifies the number of threads to use for reading data from disk.
Default: currently 1. This default applies to these kinds of
operations: copy-back,
extract, and
backup. If you
specify a value of 0, it is silently adjusted to 1. The
maximum is 15; if you supply a negative value, it is
silently adjusted to 15. For
apply-log
operations, the number of read threads is always 1
regardless of this option setting. See
Section 7.1, “Optimizing Backup Performance” and
Section 7.2, “Optimizing Restore Performance” for
advice about recommended combinations of values for
--read-threads,
--process-threads, and
--write-threads for various hardware
configurations, such as RAID or non-RAID storage devices.
--process-threads=
num_threads
| Command-Line Format | --process-threads=NUMBER | ||
| Permitted Values | Type | numeric | |
| Default | 6 | ||
| Min Value | 1 | ||
| Max Value | 15 | ||
Specifies the number of threads to use for processing data, such as compressing or uncompressing backup files.
Default: currently 6. This default applies to these kinds of
operations: extract, and
backup. It is ignored when you
use any of the options
--incremental-with-redo-log-only,
apply-incremental-backup,
copy-back, or
backup-dir-to-image.
If you specify a value of 0, it is silently adjusted to 1.
The maximum is 15; if you supply a negative value, it is
silently adjusted to 15. For
apply-log operations, the number
of process threads is always 1 regardless of this option
setting. See Section 7.1, “Optimizing Backup Performance” and
Section 7.2, “Optimizing Restore Performance” for advice about
recommended combinations of values for
--read-threads,
--process-threads, and
--write-threads for various hardware
configurations, such as RAID or non-RAID storage devices.
--write-threads=
num_threads
| Command-Line Format | --write-threads=NUMBER | ||
| Permitted Values | Type | numeric | |
| Default | 1 | ||
| Min Value | 1 | ||
| Max Value | 15 | ||
Specifies the number of threads to use for writing data to disk.
Default: currently 1. This default applies to these kinds of
operations: copy-back,
extract, and
backup. It is
ignored when you use any of the single-file backup options
list-image or
validate.
If you specify a value of 0, it is silently adjusted to 1.
The maximum is 15; if you supply a negative value, it is
silently adjusted to 15. For
apply-log operations, the number
of write threads is always 0 regardless of this option
setting. See Section 7.1, “Optimizing Backup Performance” and
Section 7.2, “Optimizing Restore Performance” for advice about
recommended combinations of values for
--read-threads,
--process-threads, and
--write-threads for various hardware
configurations, such as RAID or non-RAID storage devices.
--limit-memory=MB
| Command-Line Format | --limit-memory=MB | ||
| Permitted Values | Type | numeric | |
| Default | 100 for apply-log (without uncompression), 300 for other operations | ||
| Min Value | 0 | ||
| Max Value | 999999 | ||
Specify maximum memory in megabytes that can be used by the
mysqlbackup command. Formerly applied
only to apply-log operation, but
in MySQL Enterprise Backup 3.8 and higher it applies to all operations. Do not
include any suffixes such as mb or
kb in the option value.
Default: 100 for apply-log not
used with --uncompress, 300 for
all operations (in megabytes).
The memory limit specified by this option also caps the
number of 16MB buffers available for multithreaded
processing. For example, with a 300 MB limit, the maximum
number of buffers is 18. If additional buffers are required
because you increase the values for
--read-threads,
--process-threads,
--write-threads, and/or
--number-of-buffers, increase
the --limit-memory value proportionally.
--sleep=MS
| Command-Line Format | --sleep=MS | ||
| Permitted Values | Type | numeric | |
| Default | 0 | ||
Specify the number in milliseconds to sleep after copying a certain amount of data from InnoDB tables. Each block of data is 1024 InnoDB data pages, typically totalling 16MB. This is to limit the CPU and I/O overhead on the database server.
Default: 0 (no voluntary sleeps).
--no-locking
Disables locking during backup of non-InnoDB files, even if a connection is available. Can be used to copy non-InnoDB data with less disruption to normal database processing. There could be inconsistencies in non-InnoDB data if any changes are made while those files are being backed up.
--page-reread-time=
MS
| Command-Line Format | --page-reread-time=MS | ||
| Permitted Values | Type | numeric | |
| Default | 100 | ||
Interval in milliseconds that mysqlbackup waits before re-reading a page that fails a checksum test. A busy server could be writing a page at the same moment that mysqlbackup is reading it. Can be a floating-point number, such as 0.05 meaning 50 microseconds. Best possible resolution is 1 microsecond, but it could be worse on some platforms. Default is 100 milliseconds (0.1 seconds).
--page-reread-count=
retry_limit
| Command-Line Format | --page-reread-count=number | ||
| Permitted Values | Type | numeric | |
| Default | 500 | ||
Maximum number of re-read attempts, when a
page fails a checksum test.
A busy server could be writing a page at the same moment
that mysqlbackup is reading it. If the
same page fails this many checksum tests consecutively, with
a pause based on the
--page-reread-time option
between each attempt, the backup fails. Default is 500.
--on-disk-full={abort|abort_and_remove|warn}
| Command-Line Format | --on-disk-full=option | ||
| Permitted Values | Type | enumeration | |
| Default | abort | ||
| Valid Values | abort | ||
warn | |||
abort_and_remove | |||
Specifies the behavior when a backup process encounters a
disk-full condition. This option is only for backup
operations (backup,
backup-and-apply-log, and
backup-to-image).
abort: Abort backup, without
removing the backup directory. The disk remains full.
abort_and_remove: Abort backup and
remove the backup directory.
warn: Write a warning message every
30 seconds and retry backup until disk space becomes
available.
Default: abort.
--skip-unused-pages
Skip unused pages in tablespaces when backing up InnoDB
tables. This option is applicable to the
backup and
backup-to-image operations, but
not to
incremental
backups. The option is ignored by the
backup-and-apply-log operation.
Note that backups created with the
--skip-unused-pages option
cannot be restored using
copy-back-and-apply-log.
Unused pages are free pages often caused by bulk delete of
data. By skipping the unused pages during backups, this
option can reduce the backup sizes and thus the required
disk space and I/O resources for the operations. However,
subsequent
apply-log
operations on the backups will take more time to complete,
as the unused pages are inserted back into the tables during
the operations.
--skip-binlog
Do not include binary log files in a backup. Binary log files are included by default for all kinds of online backups (full, incremental, compressed, partial, single-file, etc.). See Section 1.4, “Files that Are Backed Up”, for details. Use this option to skip backing up binary logs if resource, performance, or other issues arise.
Due to some known issues, users should always use the
--skip-binlog option when
creating offline backups, or when creating an
incremental backup that is based on a full backup
created with the
--no-locking
option. See Appendix A, MySQL Enterprise Backup Limitations for details.
--skip-relaylog
Do not include relay log files in a backup. Relay log files are included by default for all kinds of online backups (full, incremental, compressed, partial, single-file, etc.) of a slave server. See Section 1.4, “Files that Are Backed Up”, for details. Use this option to skip backing up relay logs if resource, performance, or other issues arise.
If a user runs a FLUSH LOGS
statement while backup is in progress for a slave, the
backup process will fail. Use
the--skip-relaylog
option if you expect a FLUSH
LOGS statement will be run during the backup and
it is not necessary to include the relay logs in the
backup.
--log-bin-index[=PATH]
| Command-Line Format | --log-bin-index=FILENAME | ||
| Permitted Values | Type | file name | |
| Default | data_dir/host_name-bin.index | ||
For MySQL 5.5 and earlier, as well as all offline backups: specify the absolute path (including filename and extension) of the index file on the MySQL server that lists all the used binary log files, if it is different from the default path given below, in order to include the binary log files in the backup.
Default:
.
data_dir/host_name-bin.index
--relay-log-index[=PATH]
| Command-Line Format | --relay-log-index=FILENAME | ||
| Permitted Values | Type | file name | |
| Default | data_dir/host_name-relay-bin.index | ||
For offline backups of salve servers only: specify the absolute path (including filename and extension) of the index file on the MySQL server that lists all the used relay log files, if it is different from the default path given below, in order to include the relay log files in the backup.
Default:
.
data_dir/host_name-relay-bin.index
--master-info-file[=PATH]
| Command-Line Format | --master-info-file=FILENAME | ||
| Permitted Values | Type | file name | |
| Default | data_dir/master.info | ||
For offline backups of salve servers only: specify the absolute path (including filename and extension) of the information file in which a slave records information about its master, if it is different from the default path given below, in order to include the information file in the backup.
Default:
.
data_dir/master.info
--relaylog-info-file[=PATH]
| Command-Line Format | --relaylog-info-file=FILENAME | ||
| Permitted Values | Type | file name | |
| Default | data_dir/relay-log.info | ||
For offline backups of salve servers only: specify the absolute path (including filename and extension) of the information file in which a slave records information about the relay logs, if it is different from the default path given below, in order to include the information file in the backup.
Default:
.
data_dir/relay-log.info
| Command-Line Format | --optimistic-time=DATE-TIME | ||
| Permitted Values | Type | string | |
| Default | now | ||
Perform an optimistic backup with the value specified with the option as the “optimistic time”—a time after which the tables that have not been modified are taken as “inactive tables.” The “inactive tables”are believed to be unlikely to change during the backup process. The inactive tables are backed up in the optimistic phase of the backup, and all other tables are backed up in the normal phase. See Section 3.3.6, “Making an Optimistic Backup” for details on the concept, use cases, and command samples for an optimistic backup.
Accepted formats for specifying the option include:
now: This includes all tables into
the optimistic phase of the backup process. It is the
default value for the option when no value is
specified.
{Number}{Unit}: Indicates
the optimistic time as a time at a certain duration
into the past. {Unit} can
be any one of years,
months, hours,
and minutes. Some examples for
option strings in this format include:
5years,
2days,13months,
23hours, and
35minutes.
A date-time format in any of the following forms:
YYMMDD,
YYYYMMDD,
YYMMDDHHMMSS,
YYYYMMDDHHMMSSYY-MM-DD,
YYYY-MM-DD,
YY-MM-DD, or
HH.MM.SSYYYYMMDDTHHMMSS, as
designated by the ISO 8601 standard.
When both the optimistic-time and the
optimistic-busy-tables options are used and
they come into conflict on determining which tables are to
be backed up in the optimistic phase,
optimistic-busy-tables takes precedence
over optimistic-time.
--optimistic-busy-tables=REGEXP
| Command-Line Format | --optimistic-busy-tables=REGEXP | ||
| Permitted Values | Type | string | |
Perform an optimistic backup, using the regular expression
specified with the option to select tables that will be
skipped in the first phase of an optimistic backup, because
they are likely to be modified during the backup process.
Tables whose fully qualified names (in the form of
database_name.table_name)
are matched by the regular expression are taken as
“busy tables”, which will be backed up in the
second or the “normal” phase of the backup.
Tables whose fully qualified names are NOT matched by the
regular expression are taken as “inactive
tables”, which will be backed up in the first or the
“optimistic” phase of the backup. See
Section 3.3.6, “Making an Optimistic Backup” for details on the
concept, use cases, and command samples for an optimistic
backup.
MySQL Enterprise Backup will throw an error if the option is used but no regular expression is supplied with it.
When both the optimistic-time and the
optimistic-busy-tables options are used and
they come into conflict on determining which tables are to
be “optimistic”,
optimistic-busy-tables takes precedence
over optimistic-time.
mysqlbackup writes important progress and
error information to the stderr stream. The
information is often very valuable for tracking down problems
that occur during an operation. Starting from MySQL Enterprise
Backup 3.9, the output to the stderr stream
is also saved to a log file by default (for most
mysqlbackup operations), so that the error
information can be easily accessed in any debug process.
The message logging works like a tee process
on a Unix-like system, in which the output of a program is split
to be both displayed and saved to a file. The log file thus
produced is named in the following format:
MEB_,
where timestamp_operation.logoperation is the
mysqlbackup operation that was run (e.g.,
backup,
apply-log, etc.), and
timestamp is the date and time at
which the operation was run. Here are some examples of names for
the log files:
MEB_2013-06-24.16-32-43_backup.log MEB_2013-06-28.11-07-18_apply_log.log MEB_2013-06-29.10-08-06_list_image.log
The following options control the message logging function:
Skip message logging. Logging is turned on by default
(except for the list-image and
validate
operations; see the description for the
--messages-logdir option for details), and
it is turned off by this option.
| Command-Line Format | --messages-logdir=PATH | ||
| Permitted Values | Type | directory name | |
| Default | backup_dir/meta | ||
Specifies the path name of an existing directory for storing
the message log. If the specified directory does not exist,
message logging fails and returns an error message. When
this option is omitted, the default directory of
backup_dir/meta is used.
Use this option to turn on message logging for the
list-image
and validate operations.
Message logging is turned off by default for the two
operations, because they do not modify any files and a
message log is usually not required for debugging them.
And because the default path name of
backup_dir/meta is not meaningful for
the two operations, this option is required for both
turning on message logging and for supplying the path name
of a directory in which to save the log file. However, if
the --skip-messages-logdir option is also
specified, it takes precedence and message logging is
skipped.
The following are some examples showing how the message logging is controlled.
This creates a log file for the
backup operation in the directory
/home/backup_dir/meta due to the default
settings:
$MYSQLBACKUP -uroot --port=3306 --backup-dir=/home/backup_dir backup
This skips message logging for the
backup operation:
$MYSQLBACKUP -uroot --port=3306 --backup-dir=/home/backup_dir \
--skip-messages-logdir backup
This creates a log file for the
apply-log operation in an existing
directory named /home/teelog_dir, rather
than the default location:
$MYSQLBACKUP -uroot --port=3306 --backup-dir=/home/backup_dir \
--messages-logdir=/home/teelog_dir apply-log
This creates a log file for the
list-image operation in an existing
directory named /home/teelog_dir:
$MYSQLBACKUP -uroot --port=3306 --backup-image=/backup/my.mbi \ --messages-logdir=/home/teelog_dir list-image
There are two options for controlling the progress reporting
function of mysqlbackup:
--show-progress and
--progress-interval:
--show-progress[={stderr|stdout|file:FILENAME|fifo:FIFONAME|table|variable}]
| Command-Line Format | --show-progress[=destinations] | ||
| Permitted Values | Type | enumeration | |
| Valid Values | stderr | ||
stdout | |||
file:FILENAME | |||
fifo:FIFONAME | |||
table | |||
variable | |||
The option instructs mysqlbackup to periodically output short progress reports known as progress indicators on its operation.
The argument of the option controls the destination to which the progress indicators are sent:
stderr: Progress indicators are sent
to the standard error stream. The report is embedded in
a time-stamped mysqlbackup INFO
message. For example:
130607 12:22:38 mysqlbackup: INFO: Progress: 191 of 191 MB; state: Completed
stdout: Progress indicators are sent
to the standard output stream. A single newline
character is printed after each progress indicator.
file:FILENAME: Progress indicators
are sent to a file. Each new progress report overwrites
the file, and the file contains the most recent progress
indicator followed by a single newline character.
fifo:FIFONAME: Progress indicators
are sent to a file system FIFO. A single newline
character is printed after each progress indicator.
If there is no process reading the FIFO, the mysqlbackup process hangs at the end of the execution.
table: Progress indicators are sent
to the mysql.backup_progress table.
This requires a connection to the MySQL server, and
therefore, only works when backing up a running MySQL
instance. mysqlbackup first adds one
row of the progress report to the
mysql.backup_progress table, and then
updates the row afterwards with the latest progress
indicator. The progress indicator is stored in the
current_status column of the table.
If the backup locks the MySQL instance (for example, by
issuing a FLUSH TABLES WITH READ LOCK
statement), the progress reports are not delivered to
the mysql.backup_progress table until
the MySQL instance is unlocked.
variable: Progress indicators are
sent to the system variable
backup_progress.
The system variable
backup_progress is not yet
defined for the MySQL Server. Users need to create
their own plugin to define the variable. See
The MySQL Plugin API for more information on
user plugins.
When there is no argument specified for
--show-progress, progress indicators are
sent to stderr.
Progress can be reported to multiple destinations by
specifying the --show-progress option
several times on the command line. For example the following
command line reports progress of the backup command to
stderr and to a file called
meb_output:
mysqlbackup --show-progress --show-progress=file:meb_output --backup-dir=/full-backup
backup
The progress indicators are short strings that indicate how far the execution of a mysqlbackup operation has progressed. A progress indicator consists of one or more meters that measure the progress of the operation. For example:
Progress: 100 of 1450 MB; state: Copying .ibd files
This shows that 100 megabytes of a total of 1450 megabytes
have been copied or processed so far, and
mysqlbackup is currently copying InnoDB
data files (.ibd files).
The progress indicator string begins with
Progress:, followed by one or more meters
measuring the progress. If multiple meters are present, they
are separated by semicolons. The different types of meters
include:
Total data meter: It is always the first meter in the progress indicator. It is in the format of:
DATA of TOTAL UNIT
DATA and TOTAL are unsigned decimal integers, and UNIT is either MB (megabytes), KB (kilobytes), or bytes (1MB=1024KB and 1KB=1024 bytes).
The total data meter has two slightly different meanings depending on the mysqlbackup operation:
The amount of data copied or processed and the total amount of data to be copied or processed by the mysqlbackup operation. For example:
Progress: 200 of 1450 MB
When the operation is for, e.g.,
backup, the indicator
means 200MB is copied of 1450MB. But when the
operation is for, e.g.,
validate or
incremental,
it means 200MB is processed out of 1450MB.
Total amount of data copied or processed and an estimate for the total that will be copied by the end of the operation. The estimated total is updated as per the data on the server, as the execution of the command progresses.
For some operations such as
backup, it is not
possible to know exactly at the start of the
execution how much data will be copied or processed.
Therefore, the total data meter shows the estimated
amount of the total data for a backup. The estimate
is updated during the execution of the command. For
example:
Progress: 200 of 1450 MB
is followed by:
Progress: 200 of 1550 MB
when 100MB of data is added on the server.
If the operation is successful, the final progress indicator shows the actual amount of data copied at the end of the operation.
Compression meter: It indicates the sliding average of
the compression ratio, which is defined for each block
of data that is compressed as (orig_size -
compressed_size) / orig_size. For example:
compression: 40%
This means that after compression, the data takes 40% less space (calculated as an average over the last 10 data blocks).
The compression meter is included in the progress
indicator if the
--compress
option is enabled for the mysqlbackup
operation. The value of the compression meter is
undefined until at least 10 data blocks have been
compressed. The undefined meter value is denoted by the
'-' in the meter:
compression: -
State meter: It is a short description of the major step the command is currently executing. For example:
state: Copying InnoDB data
state: Waiting for locks
state: Copying system tablespace
state: Copying .ibd files
state: Copying non-InnoDB data
state: Completed
Here are some examples of progress indicators with different meters:
Progress: 300 of 1540 MB; state: Waiting for locks
Progress: 400 of 1450 MB; state: Copying InnoDB data: compression: 30%
The exact set of meters included in the progress indicator depends on the command and the options used for it.
| Command-Line Format | --progress-interval=SECONDS | ||
| Permitted Values | Type | numeric | |
| Default | 2 | ||
| Min Value | 1 | ||
| Max Value | 100000 | ||
Interval between progress reports in seconds. Default value is two seconds. The shortest interval is 1 second and the longest allowed interval is 100000 seconds.
These options are for creating encrypted single-file backups and for decrypting them. See Chapter 8, Encryption for Backups for more details and usage information on the encryption and decryption functions of MySQL Enterprise Backup.
Encrypt the data when creating a backup image by a
backup-to-image operation, or
when packing a backup directory into a single file with the
backup-dir-to-image subcommand.
It cannot be used with the
backup or
backup-and-apply-log subcommand.
Decrypt an encrypted backup image when performing an
extract,
image-to-backup-dir, or
copy-back-and-apply-log
operation. It is also used for performing a
validate or
list-image operation on an
encrypted backup image.
The option cannot be used in a
apply-log,
backup-and-apply-log, or
copy-back operation. For
restoration using the copy-back
subcommand, the encrypted backup image has to be unpacked
and decrypted first using the
image-to-backup-dir
or extract subcommand, together
with the --decrypt option.
| Command-Line Format | --key=KEY | ||
| Permitted Values | Type | string | |
The symmetric key for encryption and decryption of a backup
image. It should be a 256-bit key, encoded as a string of 64
hexadecimal digits. See
Chapter 8, Encryption for Backups on how to
create a key. The option is incompatible with the
--key-file option.
| Command-Line Format | --key-file=FILE | ||
| Permitted Values | Type | file name | |
The pathname to file that contains a 256-bit key, encoded as
a string of 64 hexadecimal digits, for encryption and
decryption of a backup image. The option is incompatible
with the --key option.
These options are for creating or restoring a single-file backup to or from cloud storage. See Section 3.3.5.3, “Backing Up to Cloud Storage” for more information and instructions on using cloud storage with MySQL Enterprise Backup.
Cloud service for data backup or restoration. Currently, only the Amazon S3 service is supported, and “s3” is the only value mysqlbackup accepts for this option.
The storage bucket on Amazon S3 for the backup image. The option only has meaning if Amazon S3 is used for cloud backup.
In order to perform cloud backups and restores with the
bucket, the user identified by the
--cloud-access-key-id option
must have at least the following permissions on the bucket:
s3:ListBucket: For listing
information on items in the bucket.
s3:ListBucketMultipartUploads: For
listing multipart uploads in progress to the bucket.
s3:GetObject: For retrieving
objects from the bucket.
s3:PutObject: For adding objects to
the bucket.
The Amazon S3 object key for the backup image. The option only has meaning if Amazon S3 is used for cloud backup.
AWS access key ID for logging onto Amazon S3. The option only has meaning if Amazon S3 is used for cloud backup.
AWS secret access key that goes with the AWS access key id
used in --cloud-access-key-id.
The option only has meaning if Amazon S3 is used for cloud
backup.
Region for Amazon Web Services that mysqlbackup accesses for S3. The option only has meaning if Amazon S3 is used for cloud backup.
Print trace information for cloud operations. It works
independently of --trace, which
specifies the trace level for the non-cloud operations of
mysqlbackup.
Any non-zero value for the option enables the trace function. Default value is “0.”
Proxy address and port number for overriding the environment's default proxy settings for accessing Amazon S3.
The list-image operation can
be performed on a cloud backup only if the cloud proxy
supports range headers.
These options are for backing up database servers that play specific roles in replication, or contain certain kinds of data that require special care in backing up.
--slave-info
When backing up a replication slave server, this option
captures information needed to set up an identical slave
server. It creates a file
meta/ibbackup_slave_info inside the
backup directory, containing a CHANGE
MASTER statement with the binary log position and
name of the binary log file of the master server. This
information is also printed in the
mysqlbackup output. To set up a new slave
for this master, restore the backup data on another server,
start a slave server on the backup data, and issue a
CHANGE MASTER command with the binary log
position saved in the
ibbackup_slave_info file. See
Section 6.1, “Setting Up a New Replication Slave” for instructions.
Only use this option when backing up a slave server. Its behavior is undefined when used on a master or non-replication server.
This option is not compatible with the
--no-locking option; using
both options together will make
mysqlbackup throw an error.
This option is not compatible with the
--only-innodb or
--only-innodb-with-frm
options.
--suspend-at-end
This option pauses the mysqlbackup
command when the backup procedure is close to ending. It
creates a file called
ibbackup_suspended in the backup log
group home directory and waits until you delete that file
before proceeding. This option is useful to customize
locking behavior and backup of non-InnoDB files through
custom scripting.
All tables are locked before suspending, putting the
database into a read-only state, unless you turn off locking
with the
--no-locking or
--no-connection option. The
--only-innodb and
--only-innodb-with-frm
options also prevent the locking step. Because locking all
tables could be problematic on a busy server, you might use
a combination of --only-innodb and
--suspend-at-end to back up only certain
InnoDB tables.
--exec-when-locked="utility
arg1
arg2 ..."
| Command-Line Format | --exec-when-locked="utility arg1 arg2 ..." | ||
| Permitted Values | Type | string | |
You can use this option to run a script that backs up any
information that is not included as part of the usual
backup. For example, with
--exec-when-locked,
you can use mysqldump to back up tables
from the MEMORY storage engine, which are not on disk.
Set any variable you want to use within your script before
you run mysqlbackup. In the following
example, the BACKUP_DIR environment
variable is set to point to the current backup directory
(quotes are used for the argument of
--exec-when-locked, to prevent
premature expansion of the variable
BACKUP_DIR):
On Unix or Linux systems:
export BACKUP_DIR=path_to_backupdirmysqlbackup --exec-when-locked='mysqldump mydb t1 > $BACKUP_DIR/t1.sql'other_optionsmysqlbackup_command
Or on Windows systems:
set BACKUP_DIR=path_to_backupdirmysqlbackup --exec-when-locked="mysqldump mydb t1 > %BACKUP_DIR%/t1.sql"other_optionsmysqlbackup_command
If the utility cannot be executed or returns a non-zero exit
status, the whole backup process is cancelled. If you also
use the --suspend-at-end option,
the utility specified by
--exec-when-locked is executed
after the suspension is lifted.
You can specify mysqlbackup options either on the command line or as configuration parameters inside a configuration file. This section describes the use of configuration files.
In general, mysqlbackup follows the
mysql style of processing configuration
options: [mysqlbackup] and
[client] group options are passed as
command-line options. Any command-line options that you specify
override the values from the configuration file, and in the case
of duplicate options, the last instance takes precedence.
mysqlbackup also reads options in the
[mysqld] group to detect parameters related to
the source repository when no connection to
mysqld is available.
The underscore characters in parameter names can be replaced with
dashes and treated as synonyms, similar to
mysqld parameters that use this same
convention. (See Using Options on the Command Line in the
MySQL Reference Manual for details.) The documentation typically
lists the names with underscores, to match the output of the
SHOW VARIABLES statement.
The mysqlbackup command reads the location of the MySQL data to back up from (in order of priority):
The connection information from the running database, whenever possible. Thus, in most cases, you can avoid specifying most options on the command line or in a configuration file.
Parameters you specify on the mysqlbackup command line. You can specify certain options for individual backup jobs this way.
The MySQL configuration file (by default,
my.cnf on Unix and
my.ini on Windows). The parameters are
searched for first under the [mysqlbackup]
group, then under the [client] group. You
can put common parameters that apply to most of your backup
jobs into the configuration file.
Because mysqlbackup does
not overwrite any files during the initial backup step,
the backup directory must not contain any old backup files.
mysqlbackup stops when asked to create a file
that already exists, to avoid harming an existing backup. For
convenience, specify the --with-timestamp option,
which always creates a unique timestamped subdirectory for each
backup job underneath the main backup directory.
Each set of backup data includes a configuration file,
backup-my.cnf, containing a minimal set of
configuration parameters. The mysqlbackup
command generates this file to record the settings that apply to
this backup data. Subsequent operations, such as the
apply-log process, read options from this file to
determine how the backup data is structured.
Example 5.5 Example backup-my.cnf file
Here is an example backup-my.cnf file
generated by mysqlbackup:
[mysqld] innodb_data_file_path=ibdata1:256M;ibdata2:256M:autoextend innodb_log_file_size=256M innodb_log_files_in_group=3
All paths in the generated backup-my.cnf file
point to a single backup directory. For ease of verification and
maintenance, you typically store all data for a backup inside a
single directory rather than scattered among different
directories.
During a backup, the configuration parameters that are required
for later stages (such as the restore operation) are recorded in
the backup-my.cnf file that is generated in
the backup directory. Only the minimal required parameters are
stored in backup-my.cnf, to allow you to
restore the backup to a different location without extensive
changes to that file. For example, although the
innodb_data_home_dir and
innodb_log_group_home_dir options can go into
backup-my.cnf, they are omitted when those
values are the same as the backup-dir value.