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類型的查詢