You invoke xtrabackup in one of the following modes:
--backup
mode to make a backup in a target directory
--prepare
mode to restore data from a backup (created in
--backup
mode)
--copy-back
to copy data from a backup to the location
that contained the original data; to move data instead of copying use
the alternate
--move-back
mode.
--stats
mode to scan the specified data files and print out index statistics.
When you intend to run xtrabackup in any of these modes, use the following syntax:
For all modes, the default options are read from the xtrabackup and
mysqld configuration groups from the following files in the given order:
/etc/my.cnf
/etc/mysql/my.cnf
/usr/etc/my.cnf
~/.my.cnf.
As the first parameter to xtrabackup (in place of the --defaults-file,
you may supply one of the following:
--print-defaults to have xtrabackup print the argument list and exit.
--no-defaults to forbid reading options from any file but the login file.
--defaults-file to read the default options from the given file.
--defaults-extra-file to read the specified additional file after
the global files have been read.
--defaults-group-suffix to read the configuration groups with the
given suffix. The effective group name is constructed by concatenating the default
configuration groups (xtrabackup and mysqld) with the given suffix.
--login-path to read the given path from the login file.
A large group of InnoDB options are generally read from the my.cnf configuration file, so xtrabackup boots up its embedded InnoDB in the same configuration as your current server. You usually do not
need to specify them explicitly. These options have the same behavior in InnoDB
and XtraDB. See --innodb-miscellaneous for more information.
This option controls if backup locks should be used instead of FLUSH TABLES
WITH READ LOCK on the backup stage. The option has no effect when the server does not support backup locks. This option is enabled by default,
disable with --no-backup-locks.
This option checks if Percona XtraBackup has all required privileges.
If a required privilege is missing for the current operation,
the operation terminates and prints an error message.
If a privilege is not needed for the current operation,
but is missing and may be necessary for another XtraBackup operation,
the operation is not aborted, and prints a warning.
Example output
```{.text .no-copy}
xtrabackup: Error: missing required privilege LOCK TABLES on *.*
xtrabackup: Warning: missing required privilege REPLICATION CLIENT on *.*
Do not keep files opened. When xtrabackup opens a tablespace, xtrabackup normally
doesn’t close its file handle. This operation allows xtrabackup to handle the DDL operations
correctly. However, if the number of tablespaces is huge and can not
fit into any limit, there is an option to close file handles once they are
no longer accessed. Percona XtraBackup can produce inconsistent backups
with this option enabled. Use at your own risk.
xtrabackup compresses all output data, including the transaction log and metadata files.
Version updates
Option changes
Percona XtraBackup 8.0.34-29
* The qpress/QuickLZ compression algorithm is no longer supported for compress operations.
* The ZSTD compression algorithm is moved to General Availability . This version makes ZSTD the default compression method for the --compress option.
* --compress produces \*.zst files. You can specify ZSTD compression level with the --compress-zstd-level=# option.
* --compress=lz4 produces \*.lz4 files. You can extract the contents of these files by using lz4 program.
You can extract the contents of the files by using the --decompress option. To decompress backups taken by older versions of Percona XtraBackup that used a QuickLZ compression algorithm, the --decompress option still supports qpress for backward compatibility.
Percona XtraBackup 8.0.33-28 and lower versions
The --compress option uses either the quicklz , lz4 , or ZSTD compression algorithm to compress all output data. The quicklz algorithm is chosen by default. When using --compress=quicklz or --compress , the resulting files have the qpress archive format. Every \*.qp file produced by xtrabackup is essentially a one-file qpress archive and can be extracted and uncompressed by the qpress file archiver.
* --compress=zstd produces \*.zst files. You can specify ZSTD compression level with the [--compress-zstd-level=#](#compress-zstd-level) option.
* --compress=lz4 produces \*.lz4 files. You can extract the contents of these files by using lz4 program.
You can extract the contents of the files by using the --decompress option.
Percona XtraBackup 8.0.30-23
Adds the Zstandard ( ZSTD ) compression algorithm in tech preview . The ZSTD algorithm is a fast lossless compression algorithm that targets real-time compression scenarios and better compression ratios.
To compress files using the ZSTD compression algorithm, set the --compress option to zstd. The --compress=zstd option produces *.zst files. You can extract the contents of these files with the --decompress option. Also, you can specify the ZSTD compression level with the –compress-zstd-level=#) option.
Usage: --compress-threads=#
This option specifies the number of worker threads xtrabackup uses for parallel data compression. This option defaults to 1. Parallel
compression (--compress-threads) can be used with --parallel.
For example,
--parallel=4 --compress --compress-threads=2
creates 4 I/O threads
that read and then pipe that data to 2 compression threads.
This option specifies the ZSTD compression level. Compression levels provide a trade-off between the compression speed and the size of the compressed file. A lower compression level provides faster compression speed but larger file sizes. A higher compression level provides lower compression speed but smaller file sizes. For example, set level 1 if the compression speed is the most important for you. Set level 19 if the size of the compressed files is the most important.
The default value is 1. The allowed range is from 1 to 19.
Percona XtraBackup 8.0.30-22 implemented this option.
Copy all the files in a previously made backup from the backup directory to
their original locations. This option will not copy over existing files
unless --force-non-empty-directories option is
specified.
This option specifies a list of databases and tables that should be backed
up. The option accepts the list of the form "databasename1[.table_name1]
databasename2[.table_name2] . . .".
This option specifies the path to the file containing the list of databases
and tables that should be backed up. The file can contain the list elements
of the form databasename1[.table_name1], one element per line.
The source directory for the backup. This directory should be the same as the datadir
for your MySQL server, so it should be read from my.cnf if that
exists; otherwise, you must specify it on the command line.
When combined with the --copy-back or
--move-back option, --datadir
refers to the destination directory.
Once connected to the server, to perform a backup, you will need
READ and EXECUTE permissions at a filesystem level in the
server’s datadir.
Decompresses all files in a backup previously
made with the --compress option. The
--parallel option will allow multiple files to be
decrypted simultaneously. To decompress files compressed with quicklz compression algorithm, install the qpress utility. It must be accessible within the path. Percona XtraBackup does not
automatically remove the compressed files. To clean up the backup
directory users should use --remove-original option.
The --decompress option may be used with xbstream to
decompress individual qpress files.
Decrypts all files with the .xbcrypt extension in a backup
previously made with --encrypt option. The
--parallel option will allow multiple files to be
decrypted simultaneously. Percona XtraBackup doesn’t
automatically remove the encrypted files. To clean up the backup
directory users should use --remove-original option.
Only read default options from the given file. Must be given as the first
option on the command-line. Must be a real file; it cannot be a symbolic
link.
Usage: --defaults-group=GROUP-NAMEThis option sets the group that should be read from the configuration file. This option is used by xtrabackup if you use the
--defaults-group option. It is needed for mysqld_multi deployments.
This option controls whether or not a new dump of buffer pool
content should be done.
With --dump-innodb-buffer-pool, xtrabackup
makes a request to the server to start the buffer pool dump (it
takes some time to complete and is done in the background) at the
beginning of a backup provided the status variable
innodb_buffer_pool_dump_status reports that the dump has been
completed.
If innodb_buffer_pool_dump_status reports that there is running
dump of the buffer pool, xtrabackup waits for the dump to complete
using the value of --dump-innodb-buffer-pool-timeout
The file ib_buffer_pool stores tablespace ID and page ID data to warm up the buffer pool sooner.
This option contains the number of seconds that xtrabackup should
monitor the value of innodb_buffer_pool_dump_status to
determine if buffer pool dump has completed.
This option is used in combination with
--dump-innodb-buffer-pool. By default, it is set to 10
seconds.
This option contains the percentage of the most recently used buffer pool
pages to dump.
This option is effective if --dump-innodb-buffer-pool option is set
to ON. If this option contains a value, xtrabackup sets the MySQL
system variable innodb_buffer_pool_dump_pct. As soon as the buffer pool
dump completes or it is stopped (see
--dump-innodb-buffer-pool-timeout), the value of the MySQL system
variable is restored.
This option instructs xtrabackup to encrypt backup copies of InnoDB data
files using the algorithm specified in the ENCRYPTION_ALGORITHM. Currently
supported algorithms are: AES128, AES192 and AES256
A proper length encryption key to use. It is not recommended to use this
option where there is uncontrolled access to the machine as the command line
and thus the key can be viewed as part of the process info.
The name of a file where the raw key of the appropriate length can be read
from. The file must be a simple binary (or text) file that contains exactly
the key to be used.
It is passed directly to the xtrabackup child process. See the
xtrabackup documentation for more details.
This option specifies the number of worker threads that will be used for
parallel encryption/decryption.
See the xtrabackup documentation for more details.
This option specifies the size of the internal working buffer for each
encryption thread, measured in bytes. It is passed directly to the
xtrabackup child process.
To adjust the chunk size for encrypted files, use --read-buffer-size and --encrypt-chunk-size.
This option is in tech preview. Before using this option in production, we recommend that you test restoring production from physical backups in your environment, and also use the alternative backup method for redundancy.
Implemented in Percona XtraBackup 8.0.32-26, the option lets you enable or disable the Smart memory estimation feature. The default value is OFF. Enable the feature by setting --estimate-memory=ON in the backup phase and setting the --use-free-memory-pct option in the --prepare phase. If the --estimate-memory setting is disabled, the --use-free-memory-pct setting is ignored.
An example of how to enable the Smart memory estimation feature:
When specified, it makes --copy-back and
--move-back option transfer files to non-empty
directories. No existing files will be overwritten. If files that need to
be copied/moved from the backup directory already exist in the destination
directory, it will still fail with an error.
This option specifies time in seconds that xtrabackup should wait for
queries that would block FLUSH TABLES WITH READ LOCK before running it.
If there are still such queries when the timeout expires, xtrabackup
terminates with an error. Default is 0, in which case it does not wait
for queries to complete and starts FLUSH TABLES WITH READ LOCK
immediately. Where supported xtrabackup will
automatically use Backup Locks
as a lightweight alternative to FLUSH TABLES WITH READ LOCK to copy
non-InnoDB data to avoid blocking DML queries that modify InnoDB tables.
This option specifies the query run time threshold which is used by
xtrabackup to detect long-running queries with a non-zero value of
--ftwrl-wait-timeout. FLUSH TABLES WITH READ LOCK
is not started until such long-running queries exist. This option has no
effect if --ftwrl-wait-timeout is 0. Default value
is 60 seconds. Where supported xtrabackup will
automatically use Backup Locks
as a lightweight alternative to FLUSH TABLES WITH READ LOCK to copy
non-InnoDB data to avoid blocking DML queries that modify InnoDB tables.
This option creates the xtrabackup_galera_info file which contains
the local node state at the time of the backup. Option should be used when
performing the backup of Percona XtraDB Cluster. It has no effect when
backup locks are used to create the backup.
xtrabackup needs to access the same keyring file or vault server
during prepare and copy-back but it should not depend on whether the
server keys have been purged.
--generate-transition-key creates and adds to the keyring
a transition key for xtrabackup to use if the master key used for
encryption is not found because it has been rotated and purged.
When run with this option or without any options xtrabackup displays
information about how to run the program on the command line along with all
supported options and variables with default values where appropriate.
This option enables the tracking of backup history in the
PERCONA_SCHEMA.xtrabackup_history table. An optional history series name
may be specified that will be placed with the history record for the current
backup being taken.
This option accepts a string argument that specifies the host to use when
connecting to the database server with TCP/IP. It is passed to the mysql
child process without alteration. See mysql –help for details.
This option specifies the name of the backup series stored in the
PERCONA_SCHEMA.xtrabackup_history history record to base an incremental
backup on. xtrabackup will search the history table looking for the most
recent (highest innodb_to_lsn), successful backup in the series and take
the to_lsn value to use as the starting lsn for the incremental
backup. This will be mutually exclusive with
--incremental-history-uuid, --incremental-basedir and
--incremental-lsn. If no valid lsn can be found (no series by that
name, no successful backups by that name) xtrabackup will return with an
error. It is used with the --incremental option.
This option specifies the UUID of the specific history record stored in the
PERCONA_SCHEMA.xtrabackup_history to base an incremental backup on.
--incremental-history-name, --incremental-basedir and
--incremental-lsn. If no valid lsn can be found (no success record
with that UUID) xtrabackup will return with an error. It is used with
the –incremental option.
When creating an incremental backup, you can specify the log sequence number
(LSN) instead of specifying
--incremental-basedir. For databases created in 5.1 and
later, specify the LSN as a single 64-bit integer.
Important
If a wrong LSN value is specified (a user error which Percona XtraBackup does not detect), the backup is unusable. Be careful!
There is a large group of InnoDB options that are normally read from the
my.cnf configuration file, so that xtrabackup boots up its
embedded InnoDB in the same configuration as your current server. You
normally do not need to specify these explicitly. These options have the
same behavior in InnoDB and XtraDB:
This option specifies the number of seconds xtrabackup waits between
starting FLUSH TABLES WITH READ LOCK and killing those queries that block
it. Default is 0 seconds, which means xtrabackup will not attempt to kill
any queries. In order to use this option xtrabackup user should have the
PROCESS and SUPER privileges. Where supported, xtrabackup
automatically uses Backup locks
as a lightweight alternative to FLUSH TABLES WITH READ LOCK to copy
non-InnoDB data to avoid blocking DML queries that modify InnoDB tables.
Issue LOCK TABLES FOR BACKUP if it is supported by server (otherwise use
LOCK INSTANCE FOR BACKUP) at the beginning of the backup to block all DDL
operations.
Prior to Percona XtraBackup 8.0.22-15.0, using a safe-slave-backup stops the SQL replica thread after the InnoDB tables and before the non-InnoDB tables are backed up.
As of Percona XtraBackup 8.0.22-15.0, using a safe-slave-backup option stops the SQL replica thread before copying the InnoDB files.
Move all the files in a previously made backup from the backup directory to
their original locations. As this option removes backup files, it must be
used with caution.
Disables table lock with FLUSH TABLES WITH READ
LOCK. Use it only if all your tables are InnoDB and you do not care
about the binary log position of the backup. This option shouldn’t be used if
there are any DDL statements being executed or if any updates are
happening on non-InnoDB tables (this includes the system MyISAM tables in the
mysql database), otherwise it could lead to an inconsistent backup. Where
supported xtrabackup will automatically use Backup locks
as a lightweight alternative to FLUSH TABLES WITH READ LOCK to copy
non-InnoDB data to avoid blocking DML queries that modify InnoDB tables. If
you are considering to use this because your backups are failing to acquire
the lock, this could be because of incoming replication events are preventing
the lock from succeeding. Please try using --safe-slave-backup to
momentarily stop the replication replica thread, this may help the backup to
succeed and you do not need to use this option.
The --no-server-version-check option disables the server version check.
The default behavior runs a check that compares the source system version to the Percona XtraBackup version. If the source system version is higher than the XtraBackup version, the backup is aborted with a message.
Adding the option overrides this check, and the backup proceeds, but there may be issues with the backup.
See Server Version and Backup Version Comparison for more information.
This option disables the version check. If you do not pass this option, the
automatic version check is enabled implicitly when xtrabackup runs
in the --backup mode. To disable the version check, you should pass
explicitly the --no-version-check option when invoking xtrabackup.
When the automatic version check is enabled, xtrabackup performs a
version check against the server on the backup stage after creating a server
connection. xtrabackup sends the following information to the server:
MySQL flavor and version
Operating system name
Percona Toolkit version
Perl version
Each piece of information has a unique identifier. This is a MD5 hash value
that Percona Toolkit uses to obtain statistics about how it is used. This is
a random UUID; no client information is either collected or stored.
This option specifies the number of threads to use to copy multiple data
files concurrently when creating a backup. The default value is 1 (i.e., no
concurrent transfer). In Percona XtraBackup 2.3.10 and newer, this option
can be used with the --copy-back option to copy the user
data files in parallel (redo logs and system tablespaces are copied in the
main thread).
This option accepts a string argument that specifies the port to use when
connecting to the database server with TCP/IP. It is passed to the
mysql child process without alteration. See mysql
–help for details.
Sets the read buffer size. The given value is scaled up to page size. The default size is 10MB. Use this option to increase the xbcloud/xbstream chunk size from the default size. To adjust the chunk size for encrypted files, use --read-buffer-size and --encrypt-chunk-size.
This option sets the redo log archive directory if this directory is not already set on the server. To use this option, you must run Percona XtraBackup as the owner of mysqld. Additionally, the user must have at least one of the following privileges: SUPER or SYSTEM_VARIABLES_ADMIN.
The --register-redo-log-consumer parameter is disabled by default. When enabled, this parameter lets Percona XtraBackup register as a redo log consumer at the start of the backup. The server does not remove a redo log that Percona XtraBackup (the consumer) has not yet copied. The consumer reads the redo log and manually advances the log sequence number (LSN). The server blocks the writes during the process. Based on the redo log consumption, the server determines when it can purge the log.
Implemented in Percona XtraBackup 2.4.6, this option when specified will
remove .qp, .xbcrypt and .qp.xbcrypt files after
decryption and decompression.
Uses the rsync utility to optimize local file transfers. When this
option is specified, xtrabackup uses rsync to copy
all non-InnoDB files instead of spawning a separate cp for each
file, which can be much faster for servers with a large number of databases
or tables. This option cannot be used together with --stream.
When specified, xtrabackup will stop the replica SQL thread just before
running FLUSH TABLES WITH READ LOCK and wait to start backup until
Slave_open_temp_tables in SHOW STATUS is zero. If there are no open
temporary tables, the backup will take place, otherwise the SQL thread will
be started and stopped until there are no open temporary tables. The backup
will fail if Slave_open_temp_tables does not become zero after
--safe-slave-backup-timeout seconds. The replication SQL
thread will be restarted when the backup finishes. This option is
implemented in order to deal with replicating temporary tables
and isn’t necessary with Row-Based-Replication.
Prior to Percona XtraBackup 8.0.22-15.0, using a safe-slave-backup stops the SQL replica thread after the InnoDB tables and before the non-InnoDB tables are backed up.
As of Percona XtraBackup 8.0.22-15.0, using a safe-slave-backup option stops the SQL replica thread before copying the InnoDB files.
This option is useful when backing up a replication replica server. It prints
the binary log position of the source server. It also writes the binary log
coordinates to the xtrabackup_slave_info file as a CHANGE MASTER
command. A new replica for this source can be set up by starting a replica server
on this backup and issuing a CHANGE MASTER command with the binary log
position saved in the xtrabackup_slave_info file.
This option accepts a string argument that specifies the socket to use when
connecting to the local database server with a UNIX domain socket. It is
passed to the mysql child process without alteration. See mysql
–help for details.
A regular expression against which the full tablename, in
databasename.tablename format, is matched. If the name matches, the
table is backed up. See partial backups.
Filtering by regexp for table names. Operates the same
way as --tables, but matched names are excluded from
backup. Note that this option has a higher priority than
--tables.
This option specifies the destination directory for the backup. If the
directory does not exist, xtrabackup creates it. If the directory
does exist and is empty, xtrabackup will succeed.
xtrabackup will not overwrite existing files, however; it will
fail with operating system error 17, file exists.
If this option is a relative path, it is interpreted as being relative to
the current working directory from which xtrabackup is executed.
In order to perform a backup, you need READ, WRITE, and EXECUTE
permissions at a filesystem level for the directory that you supply as the
value of --target-dir.
This option is used to enable processing the backup without accessing the
keyring vault server. In this case, xtrabackup derives the AES
encryption key from the specified passphrase and uses it to encrypt
tablespace keys of tablespaces being backed up.
If --transition-key does not have any
value, xtrabackup will ask for it. The same passphrase should be
specified for the --prepare command.
The --use-free-memory-pct is a tech preview option. Before using this option in production, we recommend that you test restoring production from physical backups in your environment, and also use the alternative backup method for redundancy.
Implemented in Percona XtraBackup 8.0.30-23, this option lets you configure the Smart memory estimation feature. The option controls the amount of free memory that can be used to --prepare a backup. The default value is 0 (zero) which defines the option as disabled. For example, if you set --use-free-memory-pct=50, then 50% of the free memory is used to prepare a backup. The maximum allowed value is 100.
This option works, only if --estimate-memory option is enabled. If the --estimate-memory option is disabled, the --use-free-memory-pct setting is ignored.
An example of how to enable the Smart memory estimation feature:
This option affects how much memory is allocated and is similar to innodb_buffer_pool_size. This option is only relevant in the --prepare phase or when analyzing statistics with --stats. The default value is 100MB. The recommended value is between 1GB to 2GB. Multiple values are supported if you provide the unit (for example, 1MB, 1M, 1GB, 1G).
This option specifies the MySQL username used when connecting to the server,
if that’s not the current user. The option accepts a string argument. See
mysql –help for details.
If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services.