2.3.1 innobackupex的相关参数介绍
由于innobackupex把功能都集成到xtrabackup中,但是很多习惯还是使用innobackupex,因为现在还有很多老版本的,只能用innobackupex备份myisam。
innobackupex --help:
1)备份相关的参数
innobackupex [--compress] [--compress-threads=NUMBER-OF-THREADS] [--compress-chunk-size=CHUNK-SIZE]
[--encrypt=ENCRYPTION-ALGORITHM] [--encrypt-threads=NUMBER-OF-THREADS] [--encrypt-chunk-size=CHUNK-SIZE]
[--encrypt-key=LITERAL-ENCRYPTION-KEY] | [--encryption-key-file=MY.KEY]
[--include=REGEXP] [--user=NAME]
[--password=WORD] [--port=PORT] [--socket=SOCKET]
[--no-timestamp] [--ibbackup=IBBACKUP-BINARY]
[--slave-info] [--galera-info] [--stream=tar|xbstream]
[--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME]
[--databases=LIST] [--no-lock]
[--tmpdir=DIRECTORY] [--tables-file=FILE]
[--history=NAME]
[--incremental] [--incremental-basedir]
[--incremental-dir] [--incremental-force-scan] [--incremental-lsn]
[--incremental-history-name=NAME] [--incremental-history-uuid=UUID]
[--close-files] [--compact]
BACKUP-ROOT-DIR
--compress:该选项表示压缩innodb数据文件的备份。
--compress-threads:该选项表示并行压缩worker线程的数量。
--compress-chunk-size:该选项表示每个压缩线程worker buffer的大小,单位是字节,默认是64K。
--encrypt:该选项表示通过ENCRYPTION_ALGORITHM的算法加密innodb数据文件的备份,目前支持的算法有ASE128,AES192,AES256。
--encrypt-threads:该选项表示并行加密的worker线程数量。
--encrypt-chunk-size:该选项表示每个加密线程worker buffer的大小,单位是字节,默认是64K。
--encrypt-key:该选项使用合适长度加密key,因为会记录到命令行,所以不推荐使用。
--encryption-key-file:该选项表示文件必须是一个简单二进制或者文本文件,加密key可通过以下命令行命令生成:openssl rand -base64 24。
--include:该选项表示使用正则表达式匹配表的名字[db.tb],要求为其指定匹配要备份的表的完整名称,即databasename.tablename。
--user:该选项表示备份账号。
--password:该选项表示备份的密码。
--port:该选项表示备份数据库的端口。
--host:该选项表示备份数据库的地址。
--databases:该选项接受的参数为数据名,如果要指定多个数据库,彼此间需要以空格隔开;如:"xtra_test dba_test",同时,在指定某数据库时,也可以只指定其中的某张表。如:"mydatabase.mytable"。该选项对innodb引擎表无效,还是会备份所有innodb表。此外,此选项也可以接受一个文件为参数,文件中每一行为一个要备份的对象。
--tables-file:该选项表示指定含有表列表的文件,格式为database.table,该选项直接传给--tables-file。
--socket:该选项表示mysql.sock所在位置,以便备份进程登录mysql。
--no-timestamp:该选项可以表示不要创建一个时间戳目录来存储备份,指定到自己想要的备份文件夹。
--ibbackup:该选项指定了使用哪个xtrabackup二进制程序。IBBACKUP-BINARY是运行percona xtrabackup的命令。这个选项适用于xtrbackup二进制不在你是搜索和工作目录,如果指定了该选项,innoabackupex自动决定用的二进制程序。
--slave-info:该选项表示对slave进行备份的时候使用,打印出master的名字和binlog pos,同样将这些信息以change master的命令写入xtrabackup_slave_info文件。可以通过基于这份备份启动一个从库。
--safe-slave-backup:该选项表示为保证一致性复制状态,这个选项停止SQL线程并且等到show status中的slave_open_temp_tables为0的时候开始备份,如果没有打开临时表,bakcup会立刻开始,否则SQL线程启动或者关闭知道没有打开的临时表。如果slave_open_temp_tables在--safe-slave-backup-timeount(默认300秒)秒之后不为0,从库sql线程会在备份完成的时候重启。
--rsync:该选项表示通过rsync工具优化本地传输,当指定这个选项,innobackupex使用rsync拷贝非Innodb文件而替换cp,当有很多DB和表的时候会快很多,不能--stream一起使用。
--kill-long-queries-timeout:该选项表示从开始执行FLUSH TABLES WITH READ LOCK到kill掉阻塞它的这些查询之间等待的秒数。默认值为0,不会kill任何查询,使用这个选项xtrabackup需要有Process和super权限。
--kill-long-query-type:该选项表示kill的类型,默认是all,可选select。
--ftwrl-wait-threshold:该选项表示检测到长查询,单位是秒,表示长查询的阈值。
--ftwrl-wait-query-type:该选项表示获得全局锁之前允许那种查询完成,默认是ALL,可选update。
--galera-info:该选项表示生成了包含创建备份时候本地节点状态的文件xtrabackup_galera_info文件,该选项只适用于备份PXC。
--stream:该选项表示流式备份的格式,backup完成之后以指定格式到STDOUT,目前只支持tar和xbstream。
--defaults-file:该选项指定了从哪个文件读取MySQL配置,必须放在命令行第一个选项的位置。
--defaults-extra-file:该选项指定了在标准defaults-file之前从哪个额外的文件读取MySQL配置,必须在命令行的第一个选项的位置。一般用于存备份用户的用户名和密码的配置文件。
----defaults-group:该选项表示从配置文件读取的组,innobakcupex多个实例部署时使用。
--no-lock:该选项表示关闭FTWRL的表锁,只有在所有表都是Innodb表并且不关心backup的binlog pos点,如果有任何DDL语句正在执行或者非InnoDB正在更新时(包括mysql库下的表),都不应该使用这个选项,后果是导致备份数据不一致,如果考虑备份因为获得锁失败,可以考虑--safe-slave-backup立刻停止复制线程。
--tmpdir:该选项表示指定--stream的时候,指定临时文件存在哪里,在streaming和拷贝到远程server之前,事务日志首先存在临时文件里。在 使用参数stream=tar备份的时候,你的xtrabackup_logfile可能会临时放在/tmp目录下,如果你备份的时候并发写入较大的话 xtrabackup_logfile可能会很大(5G+),很可能会撑满你的/tmp目录,可以通过参数--tmpdir指定目录来解决这个问题。
--history:该选项表示percona server 的备份历史记录在percona_schema.xtrabackup_history表。
--incremental:该选项表示创建一个增量备份,需要指定--incremental-basedir。
--incremental-basedir:该选项表示接受了一个字符串参数指定含有full backup的目录为增量备份的base目录,与--incremental同时使用。
--incremental-dir:该选项表示增量备份的目录。
--incremental-force-scan:该选项表示创建一份增量备份时,强制扫描所有增量备份中的数据页。
--incremental-lsn:该选项表示指定增量备份的LSN,与--incremental选项一起使用。
--incremental-history-name:该选项表示存储在PERCONA_SCHEMA.xtrabackup_history基于增量备份的历史记录的名字。Percona Xtrabackup搜索历史表查找最近(innodb_to_lsn)成功备份并且将to_lsn值作为增量备份启动出事lsn.与innobackupex--incremental-history-uuid互斥。如果没有检测到有效的lsn,xtrabackup会返回error。
--incremental-history-uuid:该选项表示存储在percona_schema.xtrabackup_history基于增量备份的特定历史记录的UUID。
--close-files:该选项表示关闭不再访问的文件句柄,当xtrabackup打开表空间通常并不关闭文件句柄目的是正确的处理DDL操作。如果表空间数量巨大,这是一种可以关闭不再访问的文件句柄的方法。使用该选项有风险,会有产生不一致备份的可能。
--compact:该选项表示创建一份没有辅助索引的紧凑的备份。
--throttle:该选项表示每秒IO操作的次数,只作用于bakcup阶段有效。apply-log和--copy-back不生效不要一起用。
2)准备阶段的参数
innobackupex --apply-log [--use-memory=B]
[--defaults-file=MY.CNF]
[--export] [--redo-only] [--ibbackup=IBBACKUP-BINARY]
BACKUP-DIR
--apply-log:该选项表示同xtrabackup的--prepare参数,一般情况下,在备份完成后,数据尚且不能用于恢复操作,因为备份的数据中可能会包含尚未提交的事务或已经提交但尚未同步至数据文件中的事务。因此,此时数据 文件仍处理不一致状态。--apply-log的作用是通过回滚未提交的事务及同步已经提交的事务至数据文件使数据文件处于一致性状态。
--use-memory:该选项表示和--apply-log选项一起使用,prepare 备份的时候,xtrabackup做crash recovery分配的内存大小,单位字节。也可(1MB,1M,1G,1GB),推荐1G。
--defaults-file:该选项指定了从哪个文件读取MySQL配置,必须放在命令行第一个选项的位置。
--export:这个选项表示开启可导出单独的表之后再导入其他Mysql中。
--redo-only:这个选项在prepare base full backup,往其中merge增量备份(但不包括最后一个)时候使用。
3)还原恢复方面的参数
innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
innobackupex --move-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
--copy-back:做数据恢复时将备份数据文件拷贝到MySQL服务器的datadir。
--move-back:这个选项与--copy-back相似,唯一的区别是它不拷贝文件,而是移动文件到目的地。这个选项移除backup文件,用时候必须小心。使用场景:没有足够的磁盘空间同事保留数据文件和Backup副本
注意:
1.datadir目录必须为空。除非指定innobackupex --force-non-empty-directorires选项指定,否则--copy-backup选项不会覆盖
2.在restore之前,必须shutdown MySQL实例,你不能将一个运行中的实例restore到datadir目录中
3.由于文件属性会被保留,大部分情况下你需要在启动实例之前将文件的属主改为mysql,这些文件将属于创建备份的用户
chown -R my5711:mysql /data1/dbrestore
以上需要在用户调用Innobackupex之前完成
--force-non-empty-directories:指定该参数时候,使得innobackupex --copy-back或--move-back选项转移文件到非空目录,已存在的文件不会被覆盖。如果--copy-back和--move-back文件需要从备份目录拷贝一个在datadir已经存在的文件,会报错失败。
4)解压解密方面的参数
innobackupex [--decompress] [--decrypt=ENCRYPTION-ALGORITHM]
[--encrypt-key=LITERAL-ENCRYPTION-KEY] | [--encryption-key-file=MY.KEY]
[--parallel=NUMBER-OF-FORKS] BACKUP-DIR
2.3.2 xtrabackup的相关参数介绍
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file,
except for login file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
Also read groups with concat(group, suffix)
--login-path=# Read this path from the login file.
-v, --version print xtrabackup version information
--target-dir=name destination directory
--backup take backup to target-dir
--stats calc statistic of datadir (offline mysqld is recommended)
--prepare prepare a backup for starting mysql server on the backup.
--export create files to import to another database when prepare.
--apply-log-only stop recovery process not to progress LSN after applying
log when prepare.
--print-param print parameter of mysqld needed for copyback.
--use-memory=# The value is used instead of buffer_pool_size
--throttle=# limit count of IO operations (pairs of read&write) per
second to IOS values (for '--backup')
--log[=name] Ignored option for MySQL option compatibility
--log-copy-interval=#
time interval between checks done by log copying thread
in milliseconds (default is 1 second).
--extra-lsndir=name (for --backup): save an extra copy of the
xtrabackup_checkpoints file in this directory.
--incremental-lsn=name
(for --backup): copy only .ibd pages newer than specified
LSN 'high:low'. ##ATTENTION##: If a wrong LSN value is
specified, it is impossible to diagnose this, causing the
backup to be unusable. Be careful!
--incremental-basedir=name
(for --backup): copy only .ibd pages newer than backup at
specified directory.
--incremental-dir=name
(for --prepare): apply .delta files and logfile in the
specified directory.
--to-archived-lsn=# Don't apply archived logs with bigger log sequence
number.
--tables=name filtering by regexp for table names.
--tables-file=name filtering by list of the exact database.table name in the
file.
--databases=name filtering by list of databases.
--databases-file=name
filtering by list of databases in the file.
--tables-exclude=name
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.
--databases-exclude=name
Excluding databases based on name, Operates the same way
as --databases, but matched names are excluded from
backup. Note that this option has a higher priority than
--databases.
--create-ib-logfile ** not work for now** creates ib_logfile* also after
'--prepare'. ### If you want create ib_logfile*, only
re-execute this command in same options. ###
--stream=name Stream all backup files to the standard output in the
specified format. Currently the only supported format is
'tar'.
--compress[=name] Compress individual backup files using the specified
compression algorithm. Currently the only supported
algorithm is 'quicklz'. It is also the default algorithm,
i.e. the one used when --compress is used without an
argument.
--compress-threads=#
Number of threads for parallel data compression. The
default value is 1.
--compress-chunk-size=#
Size of working buffer(s) for compression threads in
bytes. The default value is 64K.
--encrypt=name Encrypt individual backup files using the specified
encryption algorithm.
--encrypt-key=name Encryption key to use.
--encrypt-key-file=name
File which contains encryption key to use.
--encrypt-threads=# Number of threads for parallel data encryption. The
default value is 1.
--encrypt-chunk-size=#
Size of working buffer(S) for encryption threads in
bytes. The default value is 64K.
--compact Create a compact backup by skipping secondary index
pages.
--rebuild-indexes Rebuild secondary indexes in InnoDB tables after applying
the log. Only has effect with --prepare.
--rebuild-threads=# Use this number of threads to rebuild indexes in a
compact backup. Only has effect with --prepare and
--rebuild-indexes.
--incremental-force-scan
Perform a full-scan incremental backup even in the
presence of changed page bitmap data
--close-files do not keep files opened. Use at your own risk.
--core-file Write core on fatal signals
--copy-back Copy all the files in a previously made backup from the
backup directory to their original locations.
--move-back Move all the files in a previously made backup from the
backup directory to the actual datadir location. Use with
caution, as it removes backup files.
--galera-info This options 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. Has no effect when backup
locks are used to create the backup.
--slave-info This option is useful when backing up a replication slave
server. It prints the binary log position and name of the
master server. It also writes this information to the
"xtrabackup_slave_info" file as a "CHANGE MASTER"
command. A new slave for this master can be set up by
starting a slave server on this backup and issuing a
"CHANGE MASTER" command with the binary log position
saved in the "xtrabackup_slave_info" file.
--no-lock Use this option to disable 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. If you are considering to
use --no-lock because your backups are failing to acquire
the lock, this could be because of incoming replication
events preventing the lock from succeeding. Please try
using --safe-slave-backup to momentarily stop the
replication slave thread, this may help the backup to
succeed and you then don't need to resort to using this
option.
--lock-ddl Issue LOCK TABLES FOR BACKUP if it is supported by server
at the beginning of the backup to block all DDL
operations.
--lock-ddl-timeout=#
If LOCK TABLES FOR BACKUP does not return within given
timeout, abort the backup.
--lock-ddl-per-table
Lock DDL for each table before xtrabackup starts to copy
it and until the backup is completed.
--safe-slave-backup Stop slave SQL thread 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 slave SQL thread
will be restarted when the backup finishes.
--rsync Uses the rsync utility to optimize local file transfers.
When this option is specified, innobackupex 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.
--force-non-empty-directories
This option, when specified, makes --copy-back or
--move-back transfer files to non-empty directories. Note
that no existing files will be overwritten. If
--copy-back or --nove-back has to copy a file from the
backup directory which already exists in the destination
directory, it will still fail with an error.
--no-version-check This option disables the version check which is enabled
by the --version-check option.
--tables-compatibility-check
This option enables engine compatibility warning.
(Defaults to on; use --skip-tables-compatibility-check to disable.)
--no-backup-locks 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 backup locks are not
supported by the server. This option is enabled by
default, disable with --no-backup-locks.
--decompress Decompresses all files with the .qp extension in a backup
previously made with the --compress option.
-u, --user=name 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.
-H, --host=name This option specifies the host to use when connecting to
the database server with TCP/IP. The option accepts a
string argument. See mysql --help for details.
-P, --port=# This option specifies the port to use when connecting to
the database server with TCP/IP. The option accepts a
string argument. See mysql --help for details.
-p, --password[=name]
This option specifies the password to use when connecting
to the database. It accepts a string argument. See mysql
--help for details.
-S, --socket=name This option specifies the socket to use when connecting
to the local database server with a UNIX domain socket.
The option accepts a string argument. See mysql --help
for details.
--incremental-history-name=name
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.
--incremental-history-uuid=name
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.
--decrypt=name Decrypts all files with the .xbcrypt extension in a
backup previously made with --encrypt option.
--remove-original Remove .qp and .xbcrypt files after decryption and
decompression.
--ftwrl-wait-query-type=name
This option specifies which types of queries are allowed
to complete before innobackupex will issue the global
lock. Default is all.
--kill-long-query-type=name
This option specifies which types of queries should be
killed to unblock the global lock. Default is "all".
--history[=name] 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.
--kill-long-queries-timeout=#
This option specifies the number of seconds innobackupex
waits between starting FLUSH TABLES WITH READ LOCK and
killing those queries that block it. Default is 0
seconds, which means innobackupex will not attempt to
kill any queries.
--ftwrl-wait-timeout=#
This option specifies time in seconds that innobackupex
should wait for queries that would block FTWRL before
running it. If there are still such queries when the
timeout expires, innobackupex terminates with an error.
Default is 0, in which case innobackupex does not wait
for queries to complete and starts FTWRL immediately.
--ftwrl-wait-threshold=#
This option specifies the query run time threshold which
is used by innobackupex to detect long-running queries
with a non-zero value of --ftwrl-wait-timeout. FTWRL 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.
--debug-sleep-before-unlock=#
This is a debug-only option used by the XtraBackup test
suite.
--safe-slave-backup-timeout=#
How many seconds --safe-slave-backup should wait for
Slave_open_temp_tables to become zero. (default 300)
--binlog-info[=name]
This option controls how XtraBackup should retrieve
server's binary log coordinates corresponding to the
backup. Possible values are OFF, ON, LOCKLESS and AUTO.
See the XtraBackup manual for more information
--reencrypt-for-server-id=#
Re-encrypt tablespace keys for given server-id.
--check-privileges Check database user privileges before performing any
query.
--read-buffer-size[=#]
Set datafile read buffer size, given value is scaled up
to page size. Default is 10Mb.
--ssl-mode=name SSL connection mode.
--ssl Deprecated. Use --ssl-mode instead.
(Defaults to on; use --skip-ssl to disable.)
--ssl-verify-server-cert
Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
--ssl-ca=name CA file in PEM format.
--ssl-capath=name CA directory.
--ssl-cert=name X509 cert in PEM format.
--ssl-cipher=name SSL cipher to use.
--ssl-key=name X509 key in PEM format.
--ssl-crl=name Certificate revocation list.
--ssl-crlpath=name Certificate revocation list path.
--tls-version=name TLS version to use, permitted values are: TLSv1, TLSv1.1
-h, --datadir=name Path to the database root.
-t, --tmpdir=name Path for temporary files. Several paths may be specified,
separated by a colon (:), in this case they are used in a
round-robin fashion.
--parallel=# Number of threads to use for parallel datafiles transfer.
The default value is 1.
--log[=name] Ignored option for MySQL option compatibility
--log-bin[=name] Base name for the log sequence
--innodb[=name] Ignored option for MySQL option compatibility
--innodb-adaptive-hash-index
Enable InnoDB adaptive hash index (enabled by default).
Disable with --skip-innodb-adaptive-hash-index.
(Defaults to on; use --skip-innodb-adaptive-hash-index to disable.)
--innodb-autoextend-increment=#
Data file autoextend increment in megabytes
--innodb-buffer-pool-size=#
The size of the memory buffer InnoDB uses to cache data
and indexes of its tables.
--innodb-checksums Enable InnoDB checksums validation (enabled by default).
Disable with --skip-innodb-checksums.
(Defaults to on; use --skip-innodb-checksums to disable.)
--innodb-data-file-path=name
Path to individual files and their sizes.
--innodb-data-home-dir=name
The common part for InnoDB table spaces.
--innodb-doublewrite
Enable InnoDB doublewrite buffer (enabled by default).
Disable with --skip-innodb-doublewrite.
(Defaults to on; use --skip-innodb-doublewrite to disable.)
--innodb-io-capacity[=#]
Number of IOPs the server can do. Tunes the background IO
rate
--innodb-file-io-threads=#
Number of file I/O threads in InnoDB.
--innodb-read-io-threads=#
Number of background read I/O threads in InnoDB.
--innodb-write-io-threads=#
Number of background write I/O threads in InnoDB.
--innodb-file-per-table
Stores each InnoDB table to an .ibd file in the database
dir.
--innodb-flush-log-at-trx-commit[=#]
Set to 0 (write and flush once per second), 1 (write and
flush at each commit) or 2 (write at commit, flush once
per second).
--innodb-flush-method=name
With which method to flush data.
--innodb-force-recovery=#
Helps to save your data in case the disk image of the
database becomes corrupt.
--innodb-log-arch-dir=name
Where full logs should be archived.
--innodb-log-buffer-size=#
The size of the buffer which InnoDB uses to write log to
the log files on disk.
--innodb-log-file-size=#
Size of each log file in a log group.
--innodb-log-files-in-group=#
Number of log files in the log group. InnoDB writes to
the files in a circular fashion. Value 3 is recommended
here.
--innodb-log-group-home-dir=name
Path to InnoDB log files.
--innodb-max-dirty-pages-pct=#
Percentage of dirty pages allowed in bufferpool.
--innodb-open-files=#
How many files at the maximum InnoDB keeps open at the
same time.
--innodb-use-native-aio
Use native AIO if supported on this platform.
--innodb-page-size=#
The universal page size of the database.
--innodb-log-block-size=#
The log block size of the transaction log file. Changing
for created log file is not supported. Use on your own
risk!
--innodb-fast-checksum
Change the algorithm of checksum for the whole of
datapage to 4-bytes word based.
--innodb-doublewrite-file=name
Path to special datafile for doublewrite buffer. (default
is : not used)
--innodb-buffer-pool-filename=name
Filename to/from which to dump/load the InnoDB buffer
pool
--debug-sync=name Debug sync point. This is only used by the xtrabackup
test suite
--innodb-checksum-algorithm=name
The algorithm InnoDB uses for page checksumming. [CRC32,
STRICT_CRC32, INNODB, STRICT_INNODB, NONE, STRICT_NONE]
--innodb-log-checksum-algorithm=name
The algorithm InnoDB uses for log checksumming. [CRC32,
STRICT_CRC32, INNODB, STRICT_INNODB, NONE, STRICT_NONE]
--innodb-undo-directory=name
Directory where undo tablespace files live, this path can
be absolute.
--innodb-undo-tablespaces=#
Number of undo tablespaces to use.
--defaults-group=name
defaults group in config file (default "mysqld").
--open-files-limit=#
the maximum number of file descriptors to reserve with
setrlimit().
--redo-log-version=#
Redo log version of the backup. For --prepare only.
--server-id=# The server instance being backed up
--transition-key[=name]
Transition key to encrypt tablespace keys with.
--xtrabackup-plugin-dir=name
Directory for xtrabackup plugins.
--generate-new-master-key
Generate new master key when doing copy-back.
--generate-transition-key
Generate transition key and store it into keyring.
--apply-log-only:prepare备份的时候只执行redo阶段,用于增量备份。这个选项使在准备备份(prepare)时,只执行重做(redo)阶段,这对于增量备份非常重要。
--backup:创建备份并且放入--target-dir目录中
--close-files:不保持文件打开状态,xtrabackup打开表空间的时候通常不会关闭文件句柄,目的是为了正确处理DDL操作。如果表空间数量非常巨大并且不适合任何限制,一旦文件不在被访问的时候这个选项可以关闭文件句柄.打开这个选项会产生不一致的备份。
--compact:创建一份没有辅助索引的紧凑备份
--compress:压缩所有输出数据,包括事务日志文件和元数据文件,通过指定的压缩算法,目前唯一支持的算法是quicklz.结果文件是qpress归档格式,每个xtrabackup创建的*.qp文件都可以通过qpress程序提取或者解压缩
--compress-chunk-size=#:压缩线程工作buffer的字节大小,默认是64K
--compress-threads=#:xtrabackup进行并行数据压缩时的worker线程的数量,该选项默认值是1,并行压缩('compress-threads')可以和并行文件拷贝('parallel')一起使用。例如:'--parallel=4 --compress --compress-threads=2'会创建4个IO线程读取数据并通过管道传送给2个压缩线程。
--create-ib-logfile:这个选项目前还没有实现,目前创建Innodb事务日志,你还是需要prepare两次。
--datadir=DIRECTORY:backup的源目录,mysql实例的数据目录。从my.cnf中读取,或者命令行指定。
--defaults-extra-file=[MY.CNF]:在global files文件之后读取,必须在命令行的第一选项位置指定。
--defaults-file=[MY.CNF]:唯一从给定文件读取默认选项,必须是个真实文件,必须在命令行第一个选项位置指定。
--defaults-group=GROUP-NAME:从配置文件读取的组,innobakcupex多个实例部署时使用。
--export:为导出的表创建必要的文件
--extra-lsndir=DIRECTORY:(for --bakcup):在指定目录创建一份xtrabakcup_checkpoints文件的额外的备份。
--incremental-basedir=DIRECTORY:创建一份增量备份时,这个目录是增量别分的一份包含了full bakcup的Base数据集。
--incremental-dir=DIRECTORY:prepare增量备份的时候,增量备份在DIRECTORY结合full backup创建出一份新的full backup。
--incremental-force-scan:创建一份增量备份时,强制扫描所有增在备份中的数据页即使完全改变的page bitmap数据可用。
--incremetal-lsn=LSN:创建增量备份的时候指定lsn。
--innodb-log-arch-dir:指定包含归档日志的目录。只能和xtrabackup --prepare选项一起使用。
--innodb-miscellaneous:从My.cnf文件读取的一组Innodb选项。以便xtrabackup以同样的配置启动内置的Innodb。通常不需要显示指定。
--log-copy-interval=#:这个选项指定了log拷贝线程check的时间间隔(默认1秒)。
--log-stream:xtrabakcup不拷贝数据文件,将事务日志内容重定向到标准输出直到--suspend-at-end文件被删除。这个选项自动开启--suspend-at-end。
--no-defaults:不从任何选项文件中读取任何默认选项,必须在命令行第一个选项。
--databases=#:指定了需要备份的数据库和表。,格式为:--database="db1[.tb1] db2[.tb2]" 多个库之间以空格隔开,如果此选项不被指定,将会备份所有的数据库。
--database-file=#:指定包含数据库和表的文件格式为databasename1.tablename1为一个元素,一个元素一行。
--parallel=#:指定备份时拷贝多个数据文件并发的进程数,默认值为1。
--prepare:xtrabackup在一份通过--backup生成的备份执行还原操作,以便准备使用。
--print-default:打印程序参数列表并退出,必须放在命令行首位。
--print-param:使xtrabackup打印参数用来将数据文件拷贝到datadir并还原它们。
--rebuild_indexes:在apply事务日志之后重建innodb辅助索引,只有和--prepare一起才生效。
--rebuild_threads=#:在紧凑备份重建辅助索引的线程数,只有和--prepare和rebuild-index一起才生效。
--stats:xtrabakcup扫描指定数据文件并打印出索引统计。
--stream=name:将所有备份文件以指定格式流向标准输出,目前支持的格式有xbstream和tar。
--suspend-at-end:使xtrabackup在--target-dir目录中生成xtrabakcup_suspended文件。在拷贝数据文件之后xtrabackup不是退出而是继续拷贝日志文件并且等待知道xtrabakcup_suspended文件被删除。这项可以使xtrabackup和其他程序协同工作。
--tables=name:正则表达式匹配database.tablename。备份匹配的表。
--tables-file=name:指定文件,一个表名一行。
--target-dir=DIRECTORY:指定backup的目的地,如果目录不存在,xtrabakcup会创建。如果目录存在且为空则成功。不会覆盖已存在的文件。
--throttle=#:指定每秒操作读写对的数量。
--tmpdir=name:当使用--print-param指定的时候打印出正确的tmpdir参数。
--to-archived-lsn=LSN:指定prepare备份时apply事务日志的LSN,只能和xtarbackup --prepare选项一起用。
--user-memory = #:通过--prepare prepare备份时候分配多大内存,目的像innodb_buffer_pool_size。默认值100M如果你有足够大的内存。1-2G是推荐值,支持各种单位(1MB,1M,1GB,1G)。
--version:打印xtrabackup版本并退出。
--xbstream:支持同时压缩和流式化。需要客服传统归档tar,cpio和其他不允许动态streaming生成的文件的限制,例如动态压缩文件,xbstream超越其他传统流式/归档格式的的优点是,并发stream多个文件并且更紧凑的数据存储(所以可以和--parallel选项选项一起使用xbstream格式进行streaming)。
03.xtrabackup常用参数
基本命令:
--defaults-file:指明服务器的配置文件,此参数必须作为innobackupex的第一个参数,否则报错
--host:指明主机
--user:指明备份的用户名
--password:指明备份用户名的密码
--backup:指明为备份,此参数可以忽略
/tmp/backup:备份的目录
--backup:指明为备份
--apply-log:指明为重做日志,//应用 BACKUP-DIR 中的 xtrabackup_logfile 事务日志文件。一般情况下,在备份完成后,数据尚且不能用于恢复操作,因为备份的数据中可能会包含尚未提交的事务或已经提交但尚未同步至数据文件中的事务。因此,此时数据文件仍处于不一致状态。“准备”的主要作用正是通过回滚未提交的事务及同步已经提交的事务至数据文件使得数据文件处于一致性状态。
--copy-back:指明为恢复,//拷贝先前备份所有文件到它们的原始路径。但原路径下不能有任何文件或目录,除非指定 --force-non-empty-directories 选项。
--slave-info:备份从库的show slave status信息,仅用于在备份从库时使用
--no-lock:不锁表,仅适用于存储引擎为innodb,并且不在乎备份位置点时使用
增量备份:
--incremental://这个选项告诉 xtrabackup 创建一个增量备份,而不是完全备份。它传递到 xtrabackup 子进程。当指定这个选项,可以设置 --incremental-lsn 或 --incremental-basedir。如果这2个选项都没有被指定,--incremental-basedir 传递给 xtrabackup 默认值,默认值为:基础备份目录的第一个时间戳备份目录。
--incremental-basedir:指明此次的增量备份是基于之前的哪一次备份,增量备份仅适用于innodb和xtradb引擎
--redo-only //在“准备基本完整备份” 和 “合并所有的增量备份(除了最后一个增备)”时使用此选项。它直接传递给xtrabackup的 xtrabackup --apply-log-only 选项,使xtrabackup跳过"undo"阶段,只做"redo"操作。如果后面还有增量备份应用到这个全备,这是必要的。有关详细信息,请参阅xtrabackup文档。
--incremental-dir:恢复增量备份时,指明增量备份的目录
部分备份:
--include:使用正则表达式备份匹配到的内容;例:备份mysql库中的user表,--include='^mysql[.]user'
--table-files:如果要备份多个表,可以把多个表以”数据库名.表名“的方式写到文件中,备份时指定此文件
--databases:可以备份整个库,也可以备份库中的某个表,备份表时用”库名.表名“的方式
--export:使用部分备份恢复时用此选项,这和完整备份和增量备份有所区别
高级命令:
xtrabackup在执行备份时,会等待获得全局锁,对于长时间执行的语句,会引发锁争用的问题!
--lock-wait-timeout:指明执行flush tables with read lock前的等待时间,0表示不等待直接执行锁表命令,单位是s,若超过此参数设置的时间后还存在长时间执行的查询,则xtrabackup终止运行
--lock-wait-query-type:可以为all和update;若设置为all,表示等待所有类型的语句执行完成后再执行flush tables with read lock; 若设置update,则表示等待除了select之外sql语句执行完成,再执行锁表操作
--kill-long-queries-timeout:执行flush tables with read lock后等待的秒数
--kill-long-query-type:可以为all和select; 若为all,表示超过等待的秒数,强制终止所有的查询;若为select,表示强制终止select类型的查询