MySQL 備份 Xtrabackup
目錄mysql
1.Xtrabackup
1.1 Xtrabackup 簡介
Xtrabackup是一個對InnoDB作數據備份的工具,支持在線熱備份(備份時候不影響數據讀寫),是商業備份工做InnoDB hotbackup的一個很好的替代品。sql
特色
1.無需中止數據庫進行InnoDB熱備
2.增量備份MySQL
3.流壓縮到傳輸到其餘服務器
4.能比較容易的建立主從同步
5.備份MySQL時不會增大服務器負載數據庫
瞭解備份方式
1.熱備份:讀寫不受影響(mysqldump --> innodb)
2.溫備份:僅能夠執行讀操做(mysqldump --> myisam)
3.冷備份:離線備份,讀寫都不可用
4.邏輯備份:講數據導出文本文件中(mysqldump)
5.物理備份:講數據文件拷貝(xtrabackup,mysqlhotcopy)
6.完成備份:備份全部數據
7.增量備份:僅備份上次完整備份或者增量備份以來變化的數據
8.差別備份:僅備份上次完整備份以來變化的數據bash
1.1 Xtrabackup 原理
1.1.1 Xtrabackup 備份過程
innobackupex備份過程以下圖:
備份開始時首先會開啓一個後臺檢測進程,實時檢測mysql redo的變化,一旦發現redo中有新的日誌寫入,馬上將日誌記入後臺日誌文件xtrabackup_log中。以後複製innodb的數據文件和系統表空間文件ibdata1,待複製結束後,執行flush tables with read lock操做,複製.frm,MYI,MYD,等文件(執行flush tableswith read lock的目的是爲了防止數據表發生DDL操做,而且在這一時刻得到binlog的位置)最後會發出unlock tables,把表設置爲可讀可寫狀態,最終中止xtrabackup_log。
1.1.2 Xtrabackup 全量備份恢復
這一階段會啓動xtrabackup內嵌的innodb實例,回放xtrabackup日誌xtrabackup_log,將提交的事務信息變動應用到innodb數據/表空間,同時回滾未提交的事務(這一過程相似innodb的實例恢復)。恢復過程以下圖:服務器
1.1.3 Xtrabackup 增量備份原理
innobackupex增量備份過程當中的"增量"處理,其實主要是相對innodb而言,對myisam和其餘存儲引擎而言,它仍然是全拷貝(全備份)"。增量"備份的過程主要是經過拷貝innodb中有變動的"頁"(這些變動的數據頁指的是"頁"的LSN大於xtrabackup_checkpoints中給定的LSN)。增量備份是基於全備的,第一次增備的數據必需要基於上一次的全備,以後的每次增備都是基於上一次的增備,最終達到一致性的增備。增量備份的過程以下,和全備的過程很相似,區別僅在第2步。session
1.1.4 Xtrabackup 增量備份恢復
和全備恢復相似,也須要兩步,一是數據文件的恢復,如圖4,這裏的數據來源由3部分組成:全備份,增量備份和xtrabackup log。二是對未提交事務的回滾,如圖所示:app
1.1.5 安裝Xtrabackup
安裝Percona XtraBackup Percona yum資源庫socket
yum install -y \
http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum list|grep percona
yum install percona-xtrabackup-22
1.1.6 檢查安裝結果
[root@localhost ~]# rpm -qa|grep xtrabackup
percona-xtrabackup-22-2.2.13-1.el7.x86_64ide
Xtrabackup中主要包含兩個工具:
xtrabackup:是用於熱備innodb,xtradb表中數據的工具,不能備份其餘類型的表,也不能備份數據表結構;
innobackupex:是將xtrabackup進行封裝的perl腳本,提供了備份myisam表的能力。
經常使用選項:
--host 指定主機
--user 指定用戶名
--password 指定密碼
--port 指定端口
--databases 指定數據庫
--incremental 建立增量備份
--incremental-basedir 指定包含徹底備份的目錄
--incremental-dir 指定包含增量備份的目錄
--apply-log 對備份進行預處理操做
通常狀況下,在備份完成後,數據尚且不能用於恢復操做,由於備份的數據中可能會包含還沒有提交的事務或已經提交但還沒有同步至數據文件中的事務。所以,此時數據文件仍處理不一致狀態。「準備」的主要做用正是經過回滾未提交的事務及同步已經提交的事務至數據文件也使得數據文件處於一致性狀態。
--redo-only 不回滾未提交事務
--copy-back 恢復備份目錄
使用innobakupex備份時,其會調用xtrabackup備份全部的InnoDB表,複製全部關於表結構定義的相關文件(.frm)、以及MyISAM、MERGE、CSV和ARCHIVE表的相關文件,同時還會備份觸發器和數據庫配置信息相關的文件,這些文件會被保存至一個以時間命令的目錄中。
備份的同時,innobackupex還會在備份目錄中建立以下文件:
(1)xtrabackup_checkpoints —— 備份類型(如徹底或增量)、備份狀態(如是否已經爲prepared狀態)和LSN(日誌序列號)範圍信息;每一個InnoDB頁(一般爲16k大小)都會包含一個日誌序列號,即LSN。LSN是整個數據庫系統的系統版本號,每一個頁面相關的LSN可以代表此頁面最近是如何發生改變的。
(2)xtrabackup_binlog_info —— mysql服務器當前正在使用的二進制日誌文件及至備份這一刻爲止二進制日誌事件的位置。
(3)xtrabackup_binlog_pos_innodb —— 二進制日誌文件及用於InnoDB或XtraDB表的二進制日誌文件的當前position。
(4)xtrabackup_binary —— 備份中用到的xtrabackup的可執行文件;
(5)backup-my.cnf —— 備份命令用到的配置選項信息;
在使用innobackupex進行備份時,還可使用--no-timestamp選項來阻止命令自動建立一個以時間命名的目錄;如此一來,innobackupex命令將會建立一個BACKUP-DIR目錄來存儲備份數據。
若是要使用一個最小權限的用戶進行備份,則可基於以下命令建立此類用戶:
mysql> CREATE USER 'backuser'@'localhost' IDENTIFIED BY 'backuser' 建立用戶
mysql> REVOKE ALL PRIVILEGES,GRANT OPTION FROM 'backuser'@'localhost'; 回收此用戶全部權限
mysql> GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT ON . TO 'baskuser'@'localhost';
受權刷新、鎖定表、用戶查看服務器狀態
mysql> FLUSH PRIVILEGES; 刷新受權表
備份過程 :
注意:備份時需啓動MySQL,恢復時需關閉MySQL,清空mysql數據目錄且不能從新初始化,恢復數據後應該當即進行一次徹底備份工具
[root@localhost backup]# mysqladmin -uroot password root
Warning: Using a password on the command line interface can be insecure.
[root@localhost opt]# innobackupex --user=root --password=root --defaults-file=/etc/my.cnf /opt/
#語法解釋說明:
#1. --user=root 指定備份的用戶
#2. --password=root指定備份用戶的密碼
#3. --defaults-file=/etc/my.cnf 指定的備份數據的配置文件
#4. /opt/ 指定備份後的數據保存路徑
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 11:04:55 innobackupex: Executing a version check against the server...
170105 11:04:55 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 11:04:55 innobackupex: Connected to MySQL server
170105 11:04:55 innobackupex: Done.
170105 11:04:55 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 11:04:55 innobackupex: Connected to MySQL server
170105 11:04:55 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using server version 5.6.35-log
innobackupex: Created backup directory /opt/2017-01-05_11-04-55
170105 11:04:55 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/etc/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/opt/2017-01-05_11-04-55 --innodb_log_file_size="50331648" --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --extra-lsndir='/tmp'
innobackupex: Waiting for ibbackup (pid=25098) to suspend
innobackupex: Suspend file '/opt/2017-01-05_11-04-55/xtrabackup_suspended_2'
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
log scanned up to (1666902)
xtrabackup: Generating a list of tablespaces
[01] Copying ./ibdata1 to /opt/2017-01-05_11-04-55/ibdata1
[01] ...done
[01] Copying ./mysql/innodb_table_stats.ibd to /opt/2017-01-05_11-04-55/mysql/innodb_table_stats.ibd
[01] ...done
[01] Copying ./mysql/innodb_index_stats.ibd to /opt/2017-01-05_11-04-55/mysql/innodb_index_stats.ibd
[01] ...done
[01] Copying ./mysql/slave_relay_log_info.ibd to /opt/2017-01-05_11-04-55/mysql/slave_relay_log_info.ibd
[01] ...done
[01] Copying ./mysql/slave_master_info.ibd to /opt/2017-01-05_11-04-55/mysql/slave_master_info.ibd
[01] ...done
[01] Copying ./mysql/slave_worker_info.ibd to /opt/2017-01-05_11-04-55/mysql/slave_worker_info.ibd
[01] ...done
[01] Copying ./leco/student.ibd to /opt/2017-01-05_11-04-55/leco/student.ibd
[01] ...done
log scanned up to (1666902)
xtrabackup: Creating suspend file '/opt/2017-01-05_11-04-55/xtrabackup_suspended_2' with pid '25098'
170105 11:04:57 innobackupex: Continuing after ibbackup has suspended
170105 11:04:57 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
log scanned up to (1666902)
170105 11:04:57 innobackupex: Executing FLUSH TABLES WITH READ LOCK...
170105 11:04:57 innobackupex: All tables locked and flushed to disk
170105 11:04:57 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/var/lib/mysql/'
innobackupex: Backing up files '/var/lib/mysql//mysql/.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
innobackupex: Backing up file '/var/lib/mysql//leco/db.opt'
innobackupex: Backing up file '/var/lib/mysql//leco/student.frm'
innobackupex: Backing up files '/var/lib/mysql//performance_schema/.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
170105 11:04:58 innobackupex: Finished backing up non-InnoDB tables and files
170105 11:04:58 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
170105 11:04:58 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '1666902'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1666902)
xtrabackup: Creating suspend file '/opt/2017-01-05_11-04-55/xtrabackup_log_copied' with pid '25098'
xtrabackup: Transaction log of lsn (1666902) to (1666902) was copied.
170105 11:04:59 innobackupex: All tables unlocked
innobackupex: Backup created in directory '/opt/2017-01-05_11-04-55'
innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 430
170105 11:04:59 innobackupex: Connection to database server closed
170105 11:04:59 innobackupex: completed OK!
說明保存成功。
在備份的同時,備份數據會在備份目錄下建立一個以當前時間爲名字的目錄存放備份文件。
各文件說明:
(1)xtrabackup_checkpoints —-備份類型(如徹底或增量)、備份狀態(如是否已經沒prepare狀態)和LSN(日誌序列號)範圍信息
每一個InnoDB頁(一般大小爲16K)都會包含一個日誌序列號,即LSN,LSN是整個數據庫系統的系統版本號,每一個頁面相關的LSN可以表名此頁面最近是如何發生改變的。
backup_type = full-backuped
from_lsn = 0
to_lsn = 2097320
last_lsn = 2097320
compact = 0
(2)xtrabackup_binlog_info —-mysql服務器當前正在使用的二進制日誌及備份這一刻爲二進制日誌事件的位置
(3)xtrabackup_pos_innodb —-二進制日誌及用於InnoDB或XtraDB表的二進制日誌的當前posistion。
(4)xtrabackup_binary —-備份中用到的xtrabackup的可執行文件
(5)backup-my.cnf —- 備份命令用到的配置選項信息;
在使用innobackupex命令備份時嗎還可使用–no-timestamp選項來阻止命令自動建立一個以時間命名的目錄
innobackupex命令將會建立一個BACKUP-DIR目錄來存儲備份數據
還須要注意,備份數據庫的用戶須要具備相對應的權限,若是要使用一個最小權限的用戶進行備份可使用如下參數:
mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON . TO ‘bkpuser’@’localhost’;
mysql> FLUSH PRIVILEGES;
在使用innobackupex進行備份
[root@localhost opt]# ll /opt/
total 4
drwxr-xr-x. 5 root root 4096 Jan 5 11:04 2017-01-05_11-04-55
[root@localhost opt]# systemctl stop mysql
[root@localhost opt]# grep datadir /etc/my.cnf
datadir=/var/lib/mysql
[root@localhost opt]# cd /var/lib/mysql
[root@localhost mysql]# rm -rf *
2.1.2 全量備份恢復
準備一個完整備份(prepare)
在使用innobackup進行備份時候,還可使用--no-timestamp選項來阻止命令自動建立一個時間命名的目錄。如此一來,innobackupex命令將會建立一個BACKUP-DIR目錄來儲存備份數據在通常狀況下,在備份完成後,數據且尚不能用於恢復操做,由於備份的數據中可能包含還沒有提交的事物或者已經提交但還沒有同步至數據文件中的事物,所以此時數據文件仍然處於不一致狀態,準備的主要做用正是經過回滾未提交的事物及同步已經提交的事物至數據文件也使得數據文件處於一致狀態。
Innobackupex,命令的--apply-log選項能夠實現上述功能,
[root@localhost mysql]# innobackupex --apply-log /opt/2017-01-05_11-04-55/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 11:19:14 innobackupex: Starting the apply-log operation
IMPORTANT: Please check that the apply-log run completes successfully.
At the end of a successful apply-log run innobackupex
prints "completed OK!".
170105 11:19:14 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/opt/2017-01-05_11-04-55/backup-my.cnf" --defaults-group="mysqld" --prepare --target-dir=/opt/2017-01-05_11-04-55
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
xtrabackup: cd to /opt/2017-01-05_11-04-55
xtrabackup: This target seems to be not prepared yet.
xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1666902)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 1
xtrabackup: innodb_log_file_size = 2097152
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 1
xtrabackup: innodb_log_file_size = 2097152
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
InnoDB: Using atomics to ref count buffer pool pages
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Memory barrier is not used
InnoDB: Compressed tables use zlib 1.2.7
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, size = 100.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Highest supported file format is Barracuda.
InnoDB: The log sequence numbers 1663530 and 1663530 in ibdata files do not match the log sequence number 1666902 in the ib_logfiles!
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages
InnoDB: from the doublewrite buffer...
InnoDB: Last MySQL binlog file position 0 1451, file name mysql-bin.000001
InnoDB: 128 rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.6.24 started; log sequence number 1666902
[notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position 0 1451, file name mysql-bin.000001
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1666912
170105 11:19:16 innobackupex: Restarting xtrabackup with command: xtrabackup --defaults-file="/opt/2017-01-05_11-04-55/backup-my.cnf" --defaults-group="mysqld" --prepare --target-dir=/opt/2017-01-05_11-04-55
for creating ib_logfile*
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
xtrabackup: cd to /opt/2017-01-05_11-04-55
xtrabackup: This target seems to be already prepared.
xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
InnoDB: Using atomics to ref count buffer pool pages
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Memory barrier is not used
InnoDB: Compressed tables use zlib 1.2.7
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, size = 100.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Setting log file ./ib_logfile101 size to 48 MB
InnoDB: Setting log file ./ib_logfile1 size to 48 MB
InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
InnoDB: New log files created, LSN=1666912
InnoDB: Highest supported file format is Barracuda.
InnoDB: 128 rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.6.24 started; log sequence number 1667084
[notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position 0 1451, file name mysql-bin.000001
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1667094
170105 11:19:18 innobackupex: completed OK!
在實現準備過程當中,innobackupex一般還可使用--user-memory選項來指定其可使用的內存大小。默認一般是100M,若是有足夠的內存使用,能夠多劃分一些給內存準備prepare,以提升其完成速度。
從一個完整備份中恢復數據
Innobackupex命令的--copy-back選項用於執行恢復操做,其經過複製全部的數據相關文件到mysql服務器的DATADIR目錄來執行恢復過程,innobackupex經過backup-my.cnf來獲取DATADIR目錄相關信息。
開始恢復
[root@localhost mysql]# innobackupex --copy-back --defaults-file=/etc/my.cnf /opt/2017-01-05_11-04-55/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 11:26:34 innobackupex: Starting the copy-back operation
IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!".
innobackupex: Starting to copy files in '/opt/2017-01-05_11-04-55'
innobackupex: back to original data directory '/var/lib/mysql'
innobackupex: Copying '/opt/2017-01-05_11-04-55/xtrabackup_info' to '/var/lib/mysql/xtrabackup_info'
innobackupex: Copying '/opt/2017-01-05_11-04-55/xtrabackup_binlog_pos_innodb' to '/var/lib/mysql/xtrabackup_binlog_pos_innodb'
innobackupex: Creating directory '/var/lib/mysql/mysql'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/innodb_table_stats.ibd' to '/var/lib/mysql/mysql/innodb_table_stats.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/innodb_index_stats.ibd' to '/var/lib/mysql/mysql/innodb_index_stats.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_relay_log_info.ibd' to '/var/lib/mysql/mysql/slave_relay_log_info.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_master_info.ibd' to '/var/lib/mysql/mysql/slave_master_info.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_worker_info.ibd' to '/var/lib/mysql/mysql/slave_worker_info.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/db.frm' to '/var/lib/mysql/mysql/db.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/db.MYI' to '/var/lib/mysql/mysql/db.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/db.MYD' to '/var/lib/mysql/mysql/db.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/user.frm' to '/var/lib/mysql/mysql/user.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/user.MYI' to '/var/lib/mysql/mysql/user.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/user.MYD' to '/var/lib/mysql/mysql/user.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/func.frm' to '/var/lib/mysql/mysql/func.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/func.MYI' to '/var/lib/mysql/mysql/func.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/func.MYD' to '/var/lib/mysql/mysql/func.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/plugin.frm' to '/var/lib/mysql/mysql/plugin.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/plugin.MYI' to '/var/lib/mysql/mysql/plugin.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/plugin.MYD' to '/var/lib/mysql/mysql/plugin.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/servers.frm' to '/var/lib/mysql/mysql/servers.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/servers.MYI' to '/var/lib/mysql/mysql/servers.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/servers.MYD' to '/var/lib/mysql/mysql/servers.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/tables_priv.frm' to '/var/lib/mysql/mysql/tables_priv.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/tables_priv.MYI' to '/var/lib/mysql/mysql/tables_priv.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/tables_priv.MYD' to '/var/lib/mysql/mysql/tables_priv.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/columns_priv.frm' to '/var/lib/mysql/mysql/columns_priv.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/columns_priv.MYI' to '/var/lib/mysql/mysql/columns_priv.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/columns_priv.MYD' to '/var/lib/mysql/mysql/columns_priv.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_topic.frm' to '/var/lib/mysql/mysql/help_topic.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_topic.MYI' to '/var/lib/mysql/mysql/help_topic.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_topic.MYD' to '/var/lib/mysql/mysql/help_topic.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_category.frm' to '/var/lib/mysql/mysql/help_category.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_category.MYI' to '/var/lib/mysql/mysql/help_category.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_category.MYD' to '/var/lib/mysql/mysql/help_category.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_relation.frm' to '/var/lib/mysql/mysql/help_relation.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_relation.MYI' to '/var/lib/mysql/mysql/help_relation.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_relation.MYD' to '/var/lib/mysql/mysql/help_relation.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_keyword.frm' to '/var/lib/mysql/mysql/help_keyword.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_keyword.MYI' to '/var/lib/mysql/mysql/help_keyword.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/help_keyword.MYD' to '/var/lib/mysql/mysql/help_keyword.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_name.frm' to '/var/lib/mysql/mysql/time_zone_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_name.MYI' to '/var/lib/mysql/mysql/time_zone_name.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_name.MYD' to '/var/lib/mysql/mysql/time_zone_name.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone.frm' to '/var/lib/mysql/mysql/time_zone.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone.MYI' to '/var/lib/mysql/mysql/time_zone.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone.MYD' to '/var/lib/mysql/mysql/time_zone.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition.frm' to '/var/lib/mysql/mysql/time_zone_transition.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition.MYI' to '/var/lib/mysql/mysql/time_zone_transition.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition.MYD' to '/var/lib/mysql/mysql/time_zone_transition.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition_type.frm' to '/var/lib/mysql/mysql/time_zone_transition_type.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition_type.MYI' to '/var/lib/mysql/mysql/time_zone_transition_type.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_transition_type.MYD' to '/var/lib/mysql/mysql/time_zone_transition_type.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_leap_second.frm' to '/var/lib/mysql/mysql/time_zone_leap_second.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_leap_second.MYI' to '/var/lib/mysql/mysql/time_zone_leap_second.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/time_zone_leap_second.MYD' to '/var/lib/mysql/mysql/time_zone_leap_second.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proc.frm' to '/var/lib/mysql/mysql/proc.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proc.MYI' to '/var/lib/mysql/mysql/proc.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proc.MYD' to '/var/lib/mysql/mysql/proc.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/procs_priv.frm' to '/var/lib/mysql/mysql/procs_priv.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/procs_priv.MYI' to '/var/lib/mysql/mysql/procs_priv.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/procs_priv.MYD' to '/var/lib/mysql/mysql/procs_priv.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/general_log.frm' to '/var/lib/mysql/mysql/general_log.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/general_log.CSM' to '/var/lib/mysql/mysql/general_log.CSM'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/general_log.CSV' to '/var/lib/mysql/mysql/general_log.CSV'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slow_log.frm' to '/var/lib/mysql/mysql/slow_log.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slow_log.CSM' to '/var/lib/mysql/mysql/slow_log.CSM'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slow_log.CSV' to '/var/lib/mysql/mysql/slow_log.CSV'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/event.frm' to '/var/lib/mysql/mysql/event.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/event.MYI' to '/var/lib/mysql/mysql/event.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/event.MYD' to '/var/lib/mysql/mysql/event.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/ndb_binlog_index.frm' to '/var/lib/mysql/mysql/ndb_binlog_index.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/ndb_binlog_index.MYI' to '/var/lib/mysql/mysql/ndb_binlog_index.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/ndb_binlog_index.MYD' to '/var/lib/mysql/mysql/ndb_binlog_index.MYD'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/innodb_table_stats.frm' to '/var/lib/mysql/mysql/innodb_table_stats.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/innodb_index_stats.frm' to '/var/lib/mysql/mysql/innodb_index_stats.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_relay_log_info.frm' to '/var/lib/mysql/mysql/slave_relay_log_info.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_master_info.frm' to '/var/lib/mysql/mysql/slave_master_info.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/slave_worker_info.frm' to '/var/lib/mysql/mysql/slave_worker_info.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proxies_priv.frm' to '/var/lib/mysql/mysql/proxies_priv.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proxies_priv.MYI' to '/var/lib/mysql/mysql/proxies_priv.MYI'
innobackupex: Copying '/opt/2017-01-05_11-04-55/mysql/proxies_priv.MYD' to '/var/lib/mysql/mysql/proxies_priv.MYD'
innobackupex: Creating directory '/var/lib/mysql/leco'
innobackupex: Copying '/opt/2017-01-05_11-04-55/leco/student.ibd' to '/var/lib/mysql/leco/student.ibd'
innobackupex: Copying '/opt/2017-01-05_11-04-55/leco/db.opt' to '/var/lib/mysql/leco/db.opt'
innobackupex: Copying '/opt/2017-01-05_11-04-55/leco/student.frm' to '/var/lib/mysql/leco/student.frm'
innobackupex: Creating directory '/var/lib/mysql/performance_schema'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/db.opt' to '/var/lib/mysql/performance_schema/db.opt'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/cond_instances.frm' to '/var/lib/mysql/performance_schema/cond_instances.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_current.frm' to '/var/lib/mysql/performance_schema/events_waits_current.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_history.frm' to '/var/lib/mysql/performance_schema/events_waits_history.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_history_long.frm' to '/var/lib/mysql/performance_schema/events_waits_history_long.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_by_instance.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_by_instance.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_by_host_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_by_host_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_by_user_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_by_user_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_by_account_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_by_account_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_by_thread_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_by_thread_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_waits_summary_global_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_waits_summary_global_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/file_instances.frm' to '/var/lib/mysql/performance_schema/file_instances.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/file_summary_by_event_name.frm' to '/var/lib/mysql/performance_schema/file_summary_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/file_summary_by_instance.frm' to '/var/lib/mysql/performance_schema/file_summary_by_instance.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/socket_instances.frm' to '/var/lib/mysql/performance_schema/socket_instances.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/socket_summary_by_instance.frm' to '/var/lib/mysql/performance_schema/socket_summary_by_instance.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/socket_summary_by_event_name.frm' to '/var/lib/mysql/performance_schema/socket_summary_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/host_cache.frm' to '/var/lib/mysql/performance_schema/host_cache.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/mutex_instances.frm' to '/var/lib/mysql/performance_schema/mutex_instances.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/objects_summary_global_by_type.frm' to '/var/lib/mysql/performance_schema/objects_summary_global_by_type.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/performance_timers.frm' to '/var/lib/mysql/performance_schema/performance_timers.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/rwlock_instances.frm' to '/var/lib/mysql/performance_schema/rwlock_instances.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/setup_actors.frm' to '/var/lib/mysql/performance_schema/setup_actors.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/setup_consumers.frm' to '/var/lib/mysql/performance_schema/setup_consumers.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/setup_instruments.frm' to '/var/lib/mysql/performance_schema/setup_instruments.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/setup_objects.frm' to '/var/lib/mysql/performance_schema/setup_objects.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/setup_timers.frm' to '/var/lib/mysql/performance_schema/setup_timers.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/table_io_waits_summary_by_index_usage.frm' to '/var/lib/mysql/performance_schema/table_io_waits_summary_by_index_usage.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/table_io_waits_summary_by_table.frm' to '/var/lib/mysql/performance_schema/table_io_waits_summary_by_table.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/table_lock_waits_summary_by_table.frm' to '/var/lib/mysql/performance_schema/table_lock_waits_summary_by_table.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/threads.frm' to '/var/lib/mysql/performance_schema/threads.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_current.frm' to '/var/lib/mysql/performance_schema/events_stages_current.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_history.frm' to '/var/lib/mysql/performance_schema/events_stages_history.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_history_long.frm' to '/var/lib/mysql/performance_schema/events_stages_history_long.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_summary_by_thread_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_stages_summary_by_thread_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_summary_by_host_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_stages_summary_by_host_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_summary_by_user_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_stages_summary_by_user_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_summary_by_account_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_stages_summary_by_account_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_stages_summary_global_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_stages_summary_global_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_current.frm' to '/var/lib/mysql/performance_schema/events_statements_current.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_history.frm' to '/var/lib/mysql/performance_schema/events_statements_history.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_history_long.frm' to '/var/lib/mysql/performance_schema/events_statements_history_long.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_by_thread_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_by_thread_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_by_host_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_by_host_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_by_user_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_by_user_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_by_account_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_by_account_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_global_by_event_name.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_global_by_event_name.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/hosts.frm' to '/var/lib/mysql/performance_schema/hosts.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/users.frm' to '/var/lib/mysql/performance_schema/users.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/accounts.frm' to '/var/lib/mysql/performance_schema/accounts.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/events_statements_summary_by_digest.frm' to '/var/lib/mysql/performance_schema/events_statements_summary_by_digest.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/session_connect_attrs.frm' to '/var/lib/mysql/performance_schema/session_connect_attrs.frm'
innobackupex: Copying '/opt/2017-01-05_11-04-55/performance_schema/session_account_connect_attrs.frm' to '/var/lib/mysql/performance_schema/session_account_connect_attrs.frm'
innobackupex: Starting to copy InnoDB system tablespace
innobackupex: in '/opt/2017-01-05_11-04-55'
innobackupex: back to original InnoDB data directory '/var/lib/mysql'
innobackupex: Copying '/opt/2017-01-05_11-04-55/ibdata1' to '/var/lib/mysql/ibdata1'
innobackupex: Starting to copy InnoDB undo tablespaces
innobackupex: in '/opt/2017-01-05_11-04-55'
innobackupex: back to '/var/lib/mysql'
innobackupex: Starting to copy InnoDB log files
innobackupex: in '/opt/2017-01-05_11-04-55'
innobackupex: back to original InnoDB log directory '/var/lib/mysql'
innobackupex: Copying '/opt/2017-01-05_11-04-55/ib_logfile1' to '/var/lib/mysql/ib_logfile1'
innobackupex: Copying '/opt/2017-01-05_11-04-55/ib_logfile0' to '/var/lib/mysql/ib_logfile0'
innobackupex: Finished copying back files.
170105 11:26:35 innobackupex: completed OK!
恢復成功。
[root@localhost mysql]# ll
total 110608
-rw-r--r--. 1 root root 12582912 Jan 5 11:26 ibdata1
-rw-r--r--. 1 root root 50331648 Jan 5 11:26 ib_logfile0
-rw-r--r--. 1 root root 50331648 Jan 5 11:26 ib_logfile1
drwxr-xr-x. 2 root root 55 Jan 5 11:26 leco
drwxr-xr-x. 2 root root 4096 Jan 5 11:26 mysql
drwxr-xr-x. 2 root root 4096 Jan 5 11:26 performance_schema
-rw-r--r--. 1 root root 22 Jan 5 11:26 xtrabackup_binlog_pos_innodb
-rw-r--r--. 1 root root 584 Jan 5 11:26 xtrabackup_info
#此時數據恢復到DATADIR目錄後,還要確保全部數據文件屬性爲正確用戶和組,如MySQL,不然啓動不了。
[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# ll
total 110608
-rw-r--r--. 1 mysql mysql 12582912 Jan 5 11:26 ibdata1
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 11:26 ib_logfile0
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 11:26 ib_logfile1
drwxr-xr-x. 2 mysql mysql 55 Jan 5 11:26 leco
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 11:26 mysql
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 11:26 performance_schema
-rw-r--r--. 1 mysql mysql 22 Jan 5 11:26 xtrabackup_binlog_pos_innodb
-rw-r--r--. 1 mysql mysql 584 Jan 5 11:26 xtrabackup_info
[root@localhost mysql]# systemctl start mysql
[root@localhost mysql]# ll
total 110620
-rw-rw----. 1 mysql mysql 56 Jan 5 11:28 auto.cnf
-rw-r--r--. 1 mysql mysql 12582912 Jan 5 11:28 ibdata1
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 11:28 ib_logfile0
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 11:26 ib_logfile1
drwxr-xr-x. 2 mysql mysql 55 Jan 5 11:26 leco
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 11:26 mysql
-rw-rw----. 1 mysql mysql 120 Jan 5 11:28 mysql-bin.000001
-rw-rw----. 1 mysql mysql 19 Jan 5 11:28 mysql-bin.index
srwxrwxrwx. 1 mysql mysql 0 Jan 5 11:28 mysql.sock
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 11:26 performance_schema
-rw-r--r--. 1 mysql mysql 22 Jan 5 11:26 xtrabackup_binlog_pos_innodb
-rw-r--r--. 1 mysql mysql 584 Jan 5 11:26 xtrabackup_info
登錄測試看看沒有沒恢復過來
[root@localhost mysql]# mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| leco |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.02 sec)
mysql> use leco;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_leco |
+----------------+
| student |
+----------------+
1 row in set (0.02 sec)
mysql> desc student;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | NO | | NULL | |
| name | char(20) | NO | | NULL | |
| age | tinyint(2) | NO | | 0 | |
| dept | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> select * from student;
+----+------+-----+------+
| id | name | age | dept |
+----+------+-----+------+
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
+----+------+-----+------+
4 rows in set (0.02 sec)
到如今全備已經測試OK
先插入幾個數據,爲增量備份作準備
mysql> insert into student(id,name,age) values(2,'beijing',100);
Query OK, 1 row affected (0.01 sec)
mysql> insert into student(id,name,age) values(2,'cmz',30);
Query OK, 1 row affected (0.01 sec)
mysql> select * from student;
+----+---------+-----+------+
| id | name | age | dept |
+----+---------+-----+------+
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
| 2 | beijing | 100 | NULL |
| 2 | cmz | 30 | NULL |
+----+---------+-----+------+
6 rows in set (0.00 sec)
2.2 基於全量備份的增量備份與恢復
2.2.1 增量備份
每一個InnoDB的頁面都會包含一個LSN信息,每當相關數據發生改變,相關頁面的LSN也會自動增加,這正是InnoDB表尅有進行增量備份的基礎,即innobackupex經過上次徹底備份以後發生改變的頁面來實現。在進行增量備份時,首先要進行一次全量備份,第一次增量備份是基於全備的,以後的增量備份是基於上一次的增量備份,以此類推。
要先實現第一次增量備份。能夠實現下命令進行
基於全量備份的增量備份與恢復
作一次增量備份(基於當前最新的全量備份)
innobackupex --user=root --password=root --defaults-file=/etc/my.cnf --incremental /opt/ --incremental-basedir=/opt/2017-01-05_11-04-55/
[root@localhost mysql]# innobackupex --user=root --password=root --defaults-file=/etc/my.cnf --incremental /opt/ --incremental-basedir=/opt/2017-01-05_11-04-55/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 11:44:22 innobackupex: Executing a version check against the server...
170105 11:44:22 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 11:44:22 innobackupex: Connected to MySQL server
170105 11:44:22 innobackupex: Done.
170105 11:44:22 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 11:44:22 innobackupex: Connected to MySQL server
170105 11:44:22 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using server version 5.6.35-log
innobackupex: Created backup directory /opt/2017-01-05_11-44-22
170105 11:44:22 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/etc/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/opt/2017-01-05_11-44-22 --innodb_log_file_size="50331648" --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --extra-lsndir='/tmp' --incremental-basedir='/opt/2017-01-05_11-04-55/'
innobackupex: Waiting for ibbackup (pid=27861) to suspend
innobackupex: Suspend file '/opt/2017-01-05_11-44-22/xtrabackup_suspended_2'
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
incremental backup from 1666902 is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
log scanned up to (1669207)
xtrabackup: Generating a list of tablespaces
xtrabackup: using the full scan for incremental backup
[01] Copying ./ibdata1 to /opt/2017-01-05_11-44-22/ibdata1.delta
[01] ...done
[01] Copying ./mysql/innodb_table_stats.ibd to /opt/2017-01-05_11-44-22/mysql/innodb_table_stats.ibd.delta
[01] ...done
[01] Copying ./mysql/innodb_index_stats.ibd to /opt/2017-01-05_11-44-22/mysql/innodb_index_stats.ibd.delta
[01] ...done
[01] Copying ./mysql/slave_relay_log_info.ibd to /opt/2017-01-05_11-44-22/mysql/slave_relay_log_info.ibd.delta
[01] ...done
[01] Copying ./mysql/slave_master_info.ibd to /opt/2017-01-05_11-44-22/mysql/slave_master_info.ibd.delta
[01] ...done
[01] Copying ./mysql/slave_worker_info.ibd to /opt/2017-01-05_11-44-22/mysql/slave_worker_info.ibd.delta
[01] ...done
[01] Copying ./leco/student.ibd to /opt/2017-01-05_11-44-22/leco/student.ibd.delta
[01] ...done
log scanned up to (1669207)
xtrabackup: Creating suspend file '/opt/2017-01-05_11-44-22/xtrabackup_suspended_2' with pid '27861'
170105 11:44:24 innobackupex: Continuing after ibbackup has suspended
170105 11:44:24 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
log scanned up to (1669207)
170105 11:44:24 innobackupex: Executing FLUSH TABLES WITH READ LOCK...
170105 11:44:24 innobackupex: All tables locked and flushed to disk
170105 11:44:24 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/var/lib/mysql/'
innobackupex: Backing up files '/var/lib/mysql//mysql/.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
innobackupex: Backing up file '/var/lib/mysql//leco/db.opt'
innobackupex: Backing up file '/var/lib/mysql//leco/student.frm'
innobackupex: Backing up files '/var/lib/mysql//performance_schema/.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
170105 11:44:25 innobackupex: Finished backing up non-InnoDB tables and files
170105 11:44:25 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
170105 11:44:25 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '1669207'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1669207)
xtrabackup: Creating suspend file '/opt/2017-01-05_11-44-22/xtrabackup_log_copied' with pid '27861'
xtrabackup: Transaction log of lsn (1669207) to (1669207) was copied.
170105 11:44:26 innobackupex: All tables unlocked
innobackupex: Backup created in directory '/opt/2017-01-05_11-44-22'
innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 595
170105 11:44:26 innobackupex: Connection to database server closed
170105 11:44:26 innobackupex: completed OK!
[root@localhost 2017-01-05_11-04-55]# cat xtrabackup_checkpoints #全量備份點
backup_type = full-prepared
from_lsn = 0
to_lsn = 1666902
last_lsn = 1666902
compact = 0
[root@localhost 2017-01-05_11-04-55]# cd ../2017-01-05_11-44-22/
[root@localhost 2017-01-05_11-44-22]# ls
backup-my.cnf ibdata1.meta mysql xtrabackup_binlog_info xtrabackup_info
ibdata1.delta leco performance_schema xtrabackup_checkpoints xtrabackup_logfile
[root@localhost 2017-01-05_11-44-22]# cat xtrabackup_checkpoints #增量備份點
backup_type = incremental
from_lsn = 1666902
to_lsn = 1669207
last_lsn = 1669207
compact = 0
其中BASEDIR指的是徹底備份所在的目錄,此命令結束後,innobackupex命令會在/backup目錄中建立一個新的以時間命名的目錄以存放全部的增量備份數據,另外在執行過程增量備份只有在進行一次增量備份時,其中--incremental-basedir
應該指向上一次的增量備份所在的目錄,須要注意的是增量備份僅僅用於InnoDB或者XtraDB表,對於MyISAM表而言,執行增量備份時候其實進程的徹底備份。
2.2.2 增量恢復
準備(prepare)增量備份與總體徹底備份有一些不一樣,尤爲要注意的是,
1.須要在每一個備份(包括徹底和各個增量備份)上,將已經提交的事物進行,重放。重放以後,全部的備份數據將合併到徹底備份上。
2.基於全部的備份將未提交的事物進程回滾
[root@localhost ~]# systemctl stop mysql
[root@localhost ~]# cd /var/lib/mysql/
leco/ mysql/ performance_schema/
[root@localhost ~]# cd /var/lib/mysql/
[root@localhost mysql]# ls
auto.cnf ib_logfile0 leco mysql-bin.000001 performance_schema xtrabackup_binlog_pos_innodb
ibdata1 ib_logfile1 mysql mysql-bin.index select xtrabackup_info
[root@localhost mysql]# rm -rf *
指定全量備份
[root@localhost mysql]# innobackupex --user=root --password=root --defaults-file=/etc/my.cnf --apply-log --redo-only /opt/2017-01-05_11-04-55/
指定增量備份
[root@localhost mysql]# innobackupex --user=root --password=root --defaults-file=/etc/my.cnf --apply-log --redo-only /opt/2017-01-05_11-04-55/ --incremental-dir=/opt/2017-01-05_11-44-22/
恢復
[root@localhost mysql]# innobackupex --copy-back --defaults-file=/etc/my.cnf /opt/2017-01-05_11-04-55/
解釋:
[root@localhost mysql]# ls
ibdata1 ib_logfile0 ib_logfile1 leco mysql performance_schema xtrabackup_info
[root@localhost mysql]# chown -R mysql.mysql * #此時必定要先受權在啓動mysql
[root@localhost mysql]# ll
total 110604
-rw-r--r--. 1 mysql mysql 12582912 Jan 5 13:24 ibdata1
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 13:24 ib_logfile0
-rw-r--r--. 1 mysql mysql 50331648 Jan 5 13:24 ib_logfile1
drwxr-xr-x. 2 mysql mysql 55 Jan 5 13:24 leco
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 13:24 mysql
-rw-rw----. 1 mysql mysql 0 Jan 5 13:26 mysql-bin.index
drwxr-xr-x. 2 mysql mysql 4096 Jan 5 13:24 performance_schema
-rw-r--r--. 1 mysql mysql 652 Jan 5 13:24 xtrabackup_info
[root@localhost mysql]# systemctl start mysql
[root@localhost mysql]# ps aux|grep mysql
mysql 33422 2.0 0.1 113248 1604 ? Ss 13:26 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
root 33423 0.0 0.1 113116 1456 ? Ss 13:26 0:00 /bin/bash /usr/bin/mysql-systemd-start post
mysql 33599 21.0 11.1 475116 111352 ? Sl 13:26 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysqlmysql.sock
root 33612 0.0 0.0 112648 952 pts/3 S+ 13:26 0:00 grep --color=auto mysql
[root@localhost mysql]# mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| leco |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.03 sec)
mysql> use leco;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_leco |
+----------------+
| student |
+----------------+
1 row in set (0.00 sec)
mysql> select * from student;
+----+---------+-----+------+
| id | name | age | dept |
+----+---------+-----+------+
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
| 1 | good | 15 | NULL |
| 2 | hehe | 18 | NULL |
| 2 | beijing | 100 | NULL |
| 2 | cmz | 30 | NULL |
+----+---------+-----+------+
6 rows in set (0.00 sec)
到增量備份已經OK。
2.2.3 屢次增量備份
2.2.4 屢次增量恢復
2.3 單庫備份與恢復
[root@localhost opt]# innobackupex --user=root -password=root --defaults-file=/etc/my.cnf --database=leco /tmp/
解釋:
1.要加參數 --database
2.要指定庫名字
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 13:58:45 innobackupex: Executing a version check against the server...
170105 13:58:45 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 13:58:45 innobackupex: Connected to MySQL server
170105 13:58:45 innobackupex: Done.
170105 13:58:45 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 13:58:45 innobackupex: Connected to MySQL server
170105 13:58:45 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using server version 5.6.35-log
innobackupex: Created backup directory /tmp/2017-01-05_13-58-45
170105 13:58:45 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/etc/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp/2017-01-05_13-58-45 --innodb_log_file_size="50331648" --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --extra-lsndir='/tmp' --databases='leco'
innobackupex: Waiting for ibbackup (pid=35053) to suspend
innobackupex: Suspend file '/tmp/2017-01-05_13-58-45/xtrabackup_suspended_2'
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
log scanned up to (1667104)
xtrabackup: Generating a list of tablespaces
[01] Copying ./ibdata1 to /tmp/2017-01-05_13-58-45/ibdata1
[01] ...done
[01] Copying ./leco/student.ibd to /tmp/2017-01-05_13-58-45/leco/student.ibd
[01] ...done
log scanned up to (1667104)
xtrabackup: Creating suspend file '/tmp/2017-01-05_13-58-45/xtrabackup_suspended_2' with pid '35053'
170105 13:58:47 innobackupex: Continuing after ibbackup has suspended
170105 13:58:47 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
170105 13:58:47 innobackupex: Executing FLUSH TABLES WITH READ LOCK...
170105 13:58:47 innobackupex: All tables locked and flushed to disk
170105 13:58:47 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/var/lib/mysql/'
innobackupex: Backing up file '/var/lib/mysql//leco/db.opt'
log scanned up to (1667104)
innobackupex: Backing up file '/var/lib/mysql//leco/student.frm'
170105 13:58:47 innobackupex: Finished backing up non-InnoDB tables and files
170105 13:58:47 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
170105 13:58:47 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '1667104'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1667104)
xtrabackup: Creating suspend file '/tmp/2017-01-05_13-58-45/xtrabackup_log_copied' with pid '35053'
xtrabackup: Transaction log of lsn (1667104) to (1667104) was copied.
170105 13:58:48 innobackupex: All tables unlocked
innobackupex: Backup created in directory '/tmp/2017-01-05_13-58-45'
innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 120
170105 13:58:48 innobackupex: Connection to database server closed
170105 13:58:48 innobackupex: completed OK!
[root@localhost opt]# ll /tmp/2017-01-05_13-58-45
total 12308
-rw-r--r--. 1 root root 295 Jan 5 13:58 backup-my.cnf
-rw-r-----. 1 root root 12582912 Jan 5 13:58 ibdata1
drwx------. 2 root root 55 Jan 5 13:58 leco
-rw-r--r--. 1 root root 21 Jan 5 13:58 xtrabackup_binlog_info
-rw-r-----. 1 root root 89 Jan 5 13:58 xtrabackup_checkpoints
-rw-r--r--. 1 root root 600 Jan 5 13:58 xtrabackup_info
-rw-r-----. 1 root root 2560 Jan 5 13:58 xtrabackup_logfile
2.4 備份文件歸檔壓縮
2.4.1 壓縮
[root@localhost opt]# mkdir /tmp/db
[root@localhost opt]# innobackupex --user=root -password=root --defaults-file=/etc/my.cnf --stream=tar /tmp/db | gzip >/tmp/db/date +%F
.tar.gz
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
170105 14:05:59 innobackupex: Executing a version check against the server...
170105 14:05:59 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 14:05:59 innobackupex: Connected to MySQL server
170105 14:05:59 innobackupex: Done.
170105 14:05:59 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my.cnf;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170105 14:05:59 innobackupex: Connected to MySQL server
170105 14:05:59 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using server version 5.6.35-log
innobackupex: Created backup directory /tmp/db
170105 14:05:59 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/etc/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp --innodb_log_file_size="50331648" --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --extra-lsndir='/tmp' --stream=tar
innobackupex: Waiting for ibbackup (pid=35685) to suspend
innobackupex: Suspend file '/tmp/xtrabackup_suspended_2'
xtrabackup version 2.2.13 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 70f4be3)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
log scanned up to (1667104)
xtrabackup: Generating a list of tablespaces
[01] Streaming ./ibdata1
[01] ...done
[01] Streaming ./mysql/innodb_table_stats.ibd
[01] ...done
[01] Streaming ./mysql/innodb_index_stats.ibd
[01] ...done
[01] Streaming ./mysql/slave_relay_log_info.ibd
[01] ...done
[01] Streaming ./mysql/slave_master_info.ibd
[01] ...done
[01] Streaming ./mysql/slave_worker_info.ibd
[01] ...done
[01] Streaming ./leco/student.ibd
[01] ...done
log scanned up to (1667104)
xtrabackup: Creating suspend file '/tmp/xtrabackup_suspended_2' with pid '35685'
170105 14:06:01 innobackupex: Continuing after ibbackup has suspended
170105 14:06:01 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
170105 14:06:01 innobackupex: Executing FLUSH TABLES WITH READ LOCK...
170105 14:06:01 innobackupex: All tables locked and flushed to disk
170105 14:06:01 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/var/lib/mysql/'
innobackupex: Backing up files '/var/lib/mysql//mysql/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
log scanned up to (1667104)
innobackupex: Backing up file '/var/lib/mysql//leco/db.opt'
innobackupex: Backing up file '/var/lib/mysql//leco/student.frm'
innobackupex: Backing up files '/var/lib/mysql//performance_schema/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
170105 14:06:02 innobackupex: Finished backing up non-InnoDB tables and files
170105 14:06:02 innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
170105 14:06:02 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '1667104'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1667104)
xtrabackup: Creating suspend file '/tmp/xtrabackup_log_copied' with pid '35685'
xtrabackup: Transaction log of lsn (1667104) to (1667104) was copied.
170105 14:06:03 innobackupex: All tables unlocked
innobackupex: Backup created in directory '/tmp/db'
innobackupex: MySQL binlog position: filename 'mysql-bin.000001', position 120
170105 14:06:03 innobackupex: Connection to database server closed
innobackupex: You must use -i (--ignore-zeros) option for extraction of the tar stream.
170105 14:06:03 innobackupex: completed OK!
[root@localhost opt]# ll /tmp/db/2017-01-05.tar.gz
-rw-r--r--. 1 root root 285805 Jan 5 14:06 /tmp/db/2017-01-05.tar.gz
2.4.2 解壓
[root@localhost db]# tar -izxvf date +%F
.tar.gz#注意解壓的方式不一樣,不能直接像平時解壓文件那樣。./backup-my.cnfibdata1mysql/innodb_table_stats.ibdmysql/innodb_index_stats.ibdmysql/slave_relay_log_info.ibdmysql/slave_master_info.ibdmysql/slave_worker_info.ibdleco/student.ibdmysql/db.frmmysql/db.MYImysql/db.MYDmysql/user.frmmysql/user.MYImysql/user.MYDmysql/func.frmmysql/func.MYImysql/func.MYDmysql/plugin.frmmysql/plugin.MYImysql/plugin.MYDmysql/servers.frmmysql/servers.MYImysql/servers.MYDmysql/tables_priv.frmmysql/tables_priv.MYImysql/tables_priv.MYDmysql/columns_priv.frmmysql/columns_priv.MYImysql/columns_priv.MYDmysql/help_topic.frmmysql/help_topic.MYImysql/help_topic.MYDmysql/help_category.frmmysql/help_category.MYImysql/help_category.MYDmysql/help_relation.frmmysql/help_relation.MYImysql/help_relation.MYDmysql/help_keyword.frmmysql/help_keyword.MYImysql/help_keyword.MYDmysql/time_zone_name.frmmysql/time_zone_name.MYImysql/time_zone_name.MYDmysql/time_zone.frmmysql/time_zone.MYImysql/time_zone.MYDmysql/time_zone_transition.frmmysql/time_zone_transition.MYImysql/time_zone_transition.MYDmysql/time_zone_transition_type.frmmysql/time_zone_transition_type.MYImysql/time_zone_transition_type.MYDmysql/time_zone_leap_second.frmmysql/time_zone_leap_second.MYImysql/time_zone_leap_second.MYDmysql/proc.frmmysql/proc.MYImysql/proc.MYDmysql/procs_priv.frmmysql/procs_priv.MYImysql/procs_priv.MYDmysql/general_log.frmmysql/general_log.CSMmysql/general_log.CSVmysql/slow_log.frmmysql/slow_log.CSMmysql/slow_log.CSVmysql/event.frmmysql/event.MYImysql/event.MYDmysql/ndb_binlog_index.frmmysql/ndb_binlog_index.MYImysql/ndb_binlog_index.MYDmysql/innodb_table_stats.frmmysql/innodb_index_stats.frmmysql/slave_relay_log_info.frmmysql/slave_master_info.frmmysql/slave_worker_info.frmmysql/proxies_priv.frmmysql/proxies_priv.MYImysql/proxies_priv.MYDleco/db.optleco/student.frmperformance_schema/db.optperformance_schema/cond_instances.frmperformance_schema/events_waits_current.frmperformance_schema/events_waits_history.frmperformance_schema/events_waits_history_long.frmperformance_schema/events_waits_summary_by_instance.frmperformance_schema/events_waits_summary_by_host_by_event_name.frmperformance_schema/events_waits_summary_by_user_by_event_name.frmperformance_schema/events_waits_summary_by_account_by_event_name.frmperformance_schema/events_waits_summary_by_thread_by_event_name.frmperformance_schema/events_waits_summary_global_by_event_name.frmperformance_schema/file_instances.frmperformance_schema/file_summary_by_event_name.frmperformance_schema/file_summary_by_instance.frmperformance_schema/socket_instances.frmperformance_schema/socket_summary_by_instance.frmperformance_schema/socket_summary_by_event_name.frmperformance_schema/host_cache.frmperformance_schema/mutex_instances.frmperformance_schema/objects_summary_global_by_type.frmperformance_schema/performance_timers.frmperformance_schema/rwlock_instances.frmperformance_schema/setup_actors.frmperformance_schema/setup_consumers.frmperformance_schema/setup_instruments.frmperformance_schema/setup_objects.frmperformance_schema/setup_timers.frmperformance_schema/table_io_waits_summary_by_index_usage.frmperformance_schema/table_io_waits_summary_by_table.frmperformance_schema/table_lock_waits_summary_by_table.frmperformance_schema/threads.frmperformance_schema/events_stages_current.frmperformance_schema/events_stages_history.frmperformance_schema/events_stages_history_long.frmperformance_schema/events_stages_summary_by_thread_by_event_name.frmperformance_schema/events_stages_summary_by_host_by_event_name.frmperformance_schema/events_stages_summary_by_user_by_event_name.frmperformance_schema/events_stages_summary_by_account_by_event_name.frmperformance_schema/events_stages_summary_global_by_event_name.frmperformance_schema/events_statements_current.frmperformance_schema/events_statements_history.frmperformance_schema/events_statements_history_long.frmperformance_schema/events_statements_summary_by_thread_by_event_name.frmperformance_schema/events_statements_summary_by_host_by_event_name.frmperformance_schema/events_statements_summary_by_user_by_event_name.frmperformance_schema/events_statements_summary_by_account_by_event_name.frmperformance_schema/events_statements_summary_global_by_event_name.frmperformance_schema/hosts.frmperformance_schema/users.frmperformance_schema/accounts.frmperformance_schema/events_statements_summary_by_digest.frmperformance_schema/session_connect_attrs.frmperformance_schema/session_account_connect_attrs.frm./xtrabackup_binlog_infoxtrabackup_logfilextrabackup_checkpoints./xtrabackup_info[root@localhost db]# ls2017-01-05.tar.gz ibdata1 mysql xtrabackup_binlog_info xtrabackup_infobackup-my.cnf leco performance_schema xtrabackup_checkpoints xtrabackup_logfile[root@localhost db]#