vim /etc/my.cnf
配置文件位置及文件名根據實際狀況肯定
sql_log_bin=ON|OFF:是否記錄二進制日誌,默認爲ON //在須要的時候設置爲OFF
log_bin=/PATH/BIN_LOG_FILE:指定二進制日誌文件位置; 一般單獨存放到與數據庫不一樣的機器中 mysql
show master logs; 查看二進制日誌文件列表
flush logs; 切換二進制日誌文件(mysql命令),建立新的二進制日誌
mysqladmin flush-logs 切換二進制日誌文件(bash命令)
purge binary logs to 'mysqlbin.000005'; 刪除除mysqlbin.000005日誌以前的全部日誌,保留mysqlbin.000005及之後的日誌
reset master logs; 從新001開始記數二進制日誌(老版本)。從MariaDB10.1.6開始支持TO #,指定從#開始記數 sql
前提條件:啓用二進制日誌,並單獨存放。在mysql數據丟失時,能夠還原最新備份到丟失時刻的數據
1 徹底備份 數據庫
mysqldump -A --single-transaction --master-data=1 > /data/backup/all_mysql.sql
徹底備份數據庫文件,並存放多份到安全的地方
2 修改數據庫(在數據表中添加多條記錄。模擬數據增長,但尚未備份時數據丟失的狀況。能夠經過二進制日誌還到最新的數據) vim
mysql> insert TABLENAME(col_name,...)value(value,...)
3 數據庫文件丟失 安全
rm -rf /data/mysql/*
測試效果,清空mysql數據目錄,數據所有丟失,但開啓了二進制日誌,並單獨存放在其餘的硬盤中
4 中止mysql服務 bash
service mysqld stop
5 查看徹底備份時二進制日誌備份的最後位置,實驗時備份的最後位置爲:CHANGE MASTER TO MASTER_LOG_FILE='mariadb.000001', MASTER_LOG_POS=8944;
經過less 命令查看最新的備份文件all_mysql.sql獲取此信息 app
-- MySQL dump 10.16 Distrib 10.2.23-MariaDB, for Linux (x86_64) -- -- Host: localhost Database: -- ------------------------------------------------------ -- Server version 10.2.23-MariaDB-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Position to start replication or point-in-time recovery from -- -- CHANGE MASTER TO MASTER_LOG_FILE='mariadb.000001', MASTER_LOG_POS=8944; -- -- GTID to start replication from -- /data/backup/all_2019-05-06.sql . .
重啓mysql服務:less
service mysqld restart
登陸mysql :socket
mysql -uroot -p
臨時關閉二進制日誌,還原徹底備份:ide
mysql> set sql_log_bin=off; mysql> soruce /data/backup/all_mysql.sql
6 還原沒有備份的新數據
新開一個終端:用mysqlbinlog工具導出存放在二進制日誌中沒有備份的新記錄,開始位置爲第4步中查詢到的位置(實驗時爲8944)
mysqlbinlog --start-position=8944 /data/bin/mariadb.000001 > /data/backup/inc.sql
在原終端中繼續還原
mysql> source /data/backup/inc.sql
到此已經還原所有數據
安裝xtrabackup ,下載的rpm包,由於有依賴,因此用yum安裝
[root@Centos7 ~]#yum install percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm -y Loaded plugins: fastestmirror, langpacks Examining percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm: percona-xtrabackup-24-2.4.13-1.el7.x86_64 Marking percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package percona-xtrabackup-24.x86_64 0:2.4.13-1.el7 will be installed --> Processing Dependency: perl(DBD::mysql) for package: percona-xtrabackup-24-2.4.13-1.el7.x86_64 Determining fastest mirrors base | 3.6 kB 00:00 epel | 4.7 kB 00:00 (1/2): epel/updateinfo | 994 kB 00:02 (2/2): epel/primary_db | 6.7 MB 00:03 --> Processing Dependency: perl(Digest::MD5) for package: percona-xtrabackup-24-2.4.13-1.el7.x86_64 --> Processing Dependency: libev.so.4()(64bit) for package: percona-xtrabackup-24-2.4.13-1.el7.x86_64 --> Running transaction check ---> Package libev.x86_64 0:4.15-3.el7 will be installed ---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed ---> Package perl-Digest-MD5.x86_64 0:2.52-3.el7 will be installed --> Processing Dependency: perl(Digest::base) >= 1.00 for package: perl-Digest-MD5-2.52-3.el7.x86_64 --> Running transaction check ---> Package perl-Digest.noarch 0:1.17-245.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================== Package Arch Version Repository Size ============================================================================== Installing: percona-xtrabackup-24 x86_64 2.4.13-1.el7 /percona-xtrabackup-24-2.4.13-1.el7.x86_64 31 M Installing for dependencies: libev x86_64 4.15-3.el7 epel 43 k perl-DBD-MySQL x86_64 4.023-6.el7 base 140 k perl-Digest noarch 1.17-245.el7 base 23 k perl-Digest-MD5 x86_64 2.52-3.el7 base 30 k Transaction Summary ============================================================================== Install 1 Package (+4 Dependent packages) Total size: 32 M Total download size: 236 k Installed size: 32 M Downloading packages: (1/4): libev-4.15-3.el7.x86_64.rpm | 43 kB 00:00 (2/4): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm | 140 kB 00:00 (3/4): perl-Digest-MD5-2.52-3.el7.x86_64.rpm | 30 kB 00:00 (4/4): perl-Digest-1.17-245.el7.noarch.rpm | 23 kB 00:00 ------------------------------------------------------------------------------ Total 234 kB/s | 236 kB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libev-4.15-3.el7.x86_64 1/5 Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 2/5 Installing : perl-Digest-1.17-245.el7.noarch 3/5 Installing : perl-Digest-MD5-2.52-3.el7.x86_64 4/5 Installing : percona-xtrabackup-24-2.4.13-1.el7.x86_64 5/5 Verifying : perl-Digest-1.17-245.el7.noarch 1/5 Verifying : perl-Digest-MD5-2.52-3.el7.x86_64 2/5 Verifying : percona-xtrabackup-24-2.4.13-1.el7.x86_64 3/5 Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 4/5 Verifying : libev-4.15-3.el7.x86_64 5/5 Installed: percona-xtrabackup-24.x86_64 0:2.4.13-1.el7 Dependency Installed: libev.x86_64 0:4.15-3.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-Digest.noarch 0:1.17-245.el7 perl-Digest-MD5.x86_64 0:2.52-3.el7 Complete!
導入測試數據庫
[root@Centos7 ~]#mkdir /data/{backup,inc{1,2}} [root@Centos7 ~]#systemctl start mariadb [root@Centos7 ~]#mysql < hellodb_innodb.sql
[root@Centos7 ~]#xtrabackup --backup --target-dir=/data/backup xtrabackup: recognized server arguments: --datadir=/var/lib/mysql xtrabackup: recognized client arguments: --datadir=/var/lib/mysql --backup=1 --target-dir=/data/backup 190508 11:38:05 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' (using password: NO). 190508 11:38:05 version_check Connected to MySQL server 190508 11:38:05 version_check Executing a version check against the server... 190508 11:38:05 version_check Done. 190508 11:38:05 Connecting to MySQL server host: localhost, user: not set, password: not set, port: not set, socket: not set Using server version 5.5.60-MariaDB xtrabackup version 2.4.13 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 3e7ca7c) 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:10M:autoextend xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 2 xtrabackup: innodb_log_file_size = 5242880 InnoDB: Number of pools: 1 190508 11:38:05 >> log scanned up to (1628321) xtrabackup: Generating a list of tablespaces 190508 11:38:05 [01] Copying ./ibdata1 to /data/backup/ibdata1 190508 11:38:06 [01] ...done 190508 11:38:06 >> log scanned up to (1628321) 190508 11:38:06 Executing FLUSH NO_WRITE_TO_BINLOG TABLES... 190508 11:38:06 Executing FLUSH TABLES WITH READ LOCK... 190508 11:38:06 Starting to backup non-InnoDB tables and files 190508 11:38:06 [01] Copying ./mysql/db.frm to /data/backup/mysql/db.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/db.MYI to /data/backup/mysql/db.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/db.MYD to /data/backup/mysql/db.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/host.frm to /data/backup/mysql/host.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/host.MYI to /data/backup/mysql/host.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/host.MYD to /data/backup/mysql/host.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/user.frm to /data/backup/mysql/user.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/user.MYI to /data/backup/mysql/user.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/user.MYD to /data/backup/mysql/user.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/func.frm to /data/backup/mysql/func.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/func.MYI to /data/backup/mysql/func.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/func.MYD to /data/backup/mysql/func.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/plugin.frm to /data/backup/mysql/plugin.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/plugin.MYI to /data/backup/mysql/plugin.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/plugin.MYD to /data/backup/mysql/plugin.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/servers.frm to /data/backup/mysql/servers.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/servers.MYI to /data/backup/mysql/servers.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/servers.MYD to /data/backup/mysql/servers.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/tables_priv.frm to /data/backup/mysql/tables_priv.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/tables_priv.MYI to /data/backup/mysql/tables_priv.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/tables_priv.MYD to /data/backup/mysql/tables_priv.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/columns_priv.frm to /data/backup/mysql/columns_priv.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/columns_priv.MYI to /data/backup/mysql/columns_priv.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/columns_priv.MYD to /data/backup/mysql/columns_priv.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_topic.frm to /data/backup/mysql/help_topic.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_topic.MYI to /data/backup/mysql/help_topic.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_topic.MYD to /data/backup/mysql/help_topic.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_category.frm to /data/backup/mysql/help_category.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_category.MYI to /data/backup/mysql/help_category.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_category.MYD to /data/backup/mysql/help_category.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_relation.frm to /data/backup/mysql/help_relation.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_relation.MYI to /data/backup/mysql/help_relation.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_relation.MYD to /data/backup/mysql/help_relation.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_keyword.frm to /data/backup/mysql/help_keyword.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_keyword.MYI to /data/backup/mysql/help_keyword.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/help_keyword.MYD to /data/backup/mysql/help_keyword.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_name.frm to /data/backup/mysql/time_zone_name.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_name.MYI to /data/backup/mysql/time_zone_name.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_name.MYD to /data/backup/mysql/time_zone_name.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone.frm to /data/backup/mysql/time_zone.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone.MYI to /data/backup/mysql/time_zone.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone.MYD to /data/backup/mysql/time_zone.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition.frm to /data/backup/mysql/time_zone_transition.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition.MYI to /data/backup/mysql/time_zone_transition.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition.MYD to /data/backup/mysql/time_zone_transition.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition_type.frm to /data/backup/mysql/time_zone_transition_type.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition_type.MYI to /data/backup/mysql/time_zone_transition_type.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_transition_type.MYD to /data/backup/mysql/time_zone_transition_type.MYD 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_leap_second.frm to /data/backup/mysql/time_zone_leap_second.frm 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_leap_second.MYI to /data/backup/mysql/time_zone_leap_second.MYI 190508 11:38:06 [01] ...done 190508 11:38:06 [01] Copying ./mysql/time_zone_leap_second.MYD to /data/backup/mysql/time_zone_leap_second.MYD 190508 11:38:06 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proc.frm to /data/backup/mysql/proc.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proc.MYI to /data/backup/mysql/proc.MYI 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proc.MYD to /data/backup/mysql/proc.MYD 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/procs_priv.frm to /data/backup/mysql/procs_priv.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/procs_priv.MYI to /data/backup/mysql/procs_priv.MYI 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/procs_priv.MYD to /data/backup/mysql/procs_priv.MYD 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/general_log.frm to /data/backup/mysql/general_log.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/general_log.CSM to /data/backup/mysql/general_log.CSM 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/general_log.CSV to /data/backup/mysql/general_log.CSV 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/slow_log.frm to /data/backup/mysql/slow_log.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/slow_log.CSM to /data/backup/mysql/slow_log.CSM 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/slow_log.CSV to /data/backup/mysql/slow_log.CSV 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/event.frm to /data/backup/mysql/event.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/event.MYI to /data/backup/mysql/event.MYI 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/event.MYD to /data/backup/mysql/event.MYD 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/ndb_binlog_index.frm to /data/backup/mysql/ndb_binlog_index.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/ndb_binlog_index.MYI to /data/backup/mysql/ndb_binlog_index.MYI 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/ndb_binlog_index.MYD to /data/backup/mysql/ndb_binlog_index.MYD 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proxies_priv.frm to /data/backup/mysql/proxies_priv.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proxies_priv.MYI to /data/backup/mysql/proxies_priv.MYI 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./mysql/proxies_priv.MYD to /data/backup/mysql/proxies_priv.MYD 190508 11:38:07 [01] ...done 190508 11:38:07 [00] Writing /data/backup/test/db.opt 190508 11:38:07 [00] ...done 190508 11:38:07 [01] Copying ./performance_schema/db.opt to /data/backup/performance_schema/db.opt 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/cond_instances.frm to /data/backup/performance_schema/cond_instances.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_current.frm to /data/backup/performance_schema/events_waits_current.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_history.frm to /data/backup/performance_schema/events_waits_history.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_history_long.frm to /data/backup/performance_schema/events_waits_history_long.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /data/backup/performance_schema/events_waits_summary_by_instance.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /data/backup/performance_schema/events_waits_summary_by_thread_by_event_name.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /data/backup/performance_schema/events_waits_summary_global_by_event_name.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/file_instances.frm to /data/backup/performance_schema/file_instances.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /data/backup/performance_schema/file_summary_by_event_name.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/file_summary_by_instance.frm to /data/backup/performance_schema/file_summary_by_instance.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/mutex_instances.frm to /data/backup/performance_schema/mutex_instances.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/performance_timers.frm to /data/backup/performance_schema/performance_timers.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/rwlock_instances.frm to /data/backup/performance_schema/rwlock_instances.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/setup_consumers.frm to /data/backup/performance_schema/setup_consumers.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/setup_instruments.frm to /data/backup/performance_schema/setup_instruments.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/setup_timers.frm to /data/backup/performance_schema/setup_timers.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./performance_schema/threads.frm to /data/backup/performance_schema/threads.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/db.opt to /data/backup/hellodb/db.opt 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/classes.frm to /data/backup/hellodb/classes.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/coc.frm to /data/backup/hellodb/coc.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/courses.frm to /data/backup/hellodb/courses.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/scores.frm to /data/backup/hellodb/scores.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/students.frm to /data/backup/hellodb/students.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/teachers.frm to /data/backup/hellodb/teachers.frm 190508 11:38:07 [01] ...done 190508 11:38:07 [01] Copying ./hellodb/toc.frm to /data/backup/hellodb/toc.frm 190508 11:38:07 [01] ...done 190508 11:38:07 Finished backing up non-InnoDB tables and files 190508 11:38:07 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point (for incremental): '1628321' xtrabackup: Stopping log copying thread. .190508 11:38:07 >> log scanned up to (1628321)
190508 11:38:07 Executing UNLOCK TABLES
190508 11:38:07 All tables unlocked
190508 11:38:07 Backup created in directory '/data/backup/'
190508 11:38:07 [00] Writing /data/backup/backup-my.cnf
190508 11:38:07 [00] ...done
190508 11:38:07 [00] Writing /data/backup/xtrabackup_info
190508 11:38:07 [00] ...done
xtrabackup: Transaction log of lsn (1628321) to (1628321) was copied.
190508 11:38:07 completed OK!
scp -r /data/backup/ 目標主機:/data/backup/ 將備份數據傳送到目標主機上恢復 ```bash [root@Centos7 ~]#scp -r /data/backup/ 192.168.37.17:/data/ The authenticity of host '192.168.37.17 (192.168.37.17)' can't be established. ECDSA key fingerprint is SHA256:cgmQO7rW7wGdDrQs+/DxG7bbPUL4cTAZgmJ0b1BIvFc. ECDSA key fingerprint is MD5:67:ad:d6:de:75:02:e5:38:bc:e5:cc:ef:b6:e8:87:a9. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.37.17' (ECDSA) to the list of known hosts. root@192.168.37.17's password: xtrabackup_logfile 100% 2560 189.1KB/s 00:00 ibdata1 100% 18MB 61.4MB/s 00:00 db.frm 100% 9582 3.5MB/s 00:00 db.MYI 100% 5120 2.6MB/s 00:00 db.MYD 100% 880 856.0KB/s 00:00 host.frm 100% 9510 4.9MB/s 00:00 host.MYI 100% 2048 1.0MB/s 00:00 host.MYD 100% 0 0.0KB/s 00:00 user.frm 100% 10KB 5.4MB/s 00:00 user.MYI 100% 2048 1.2MB/s 00:00 user.MYD 100% 340 303.3KB/s 00:00 func.frm 100% 8665 4.7MB/s 00:00 func.MYI 100% 1024 853.3KB/s 00:00 func.MYD 100% 0 0.0KB/s 00:00 plugin.frm 100% 8586 3.7MB/s 00:00 plugin.MYI 100% 1024 1.1MB/s 00:00 plugin.MYD 100% 0 0.0KB/s 00:00 servers.frm 100% 8838 5.8MB/s 00:00 servers.MYI 100% 1024 932.2KB/s 00:00 servers.MYD 100% 0 0.0KB/s 00:00 tables_priv.frm 100% 8955 4.6MB/s 00:00 tables_priv.MYI 100% 4096 3.2MB/s 00:00 tables_priv.MYD 100% 0 0.0KB/s 00:00 columns_priv.frm 100% 8820 3.5MB/s 00:00 columns_priv.MYI 100% 4096 2.8MB/s 00:00 columns_priv.MYD 100% 0 0.0KB/s 00:00 help_topic.frm 100% 8770 5.3MB/s 00:00 help_topic.MYI 100% 20KB 9.2MB/s 00:00 help_topic.MYD 100% 440KB 53.1MB/s 00:00 help_category.frm 100% 8700 4.1MB/s 00:00 help_category.MYI 100% 3072 1.6MB/s 00:00 help_category.MYD 100% 1092 760.5KB/s 00:00 help_relation.frm 100% 8630 3.8MB/s 00:00 help_relation.MYI 100% 19KB 2.9MB/s 00:00 help_relation.MYD 100% 9252 6.7MB/s 00:00 help_keyword.frm 100% 8612 5.2MB/s 00:00 help_keyword.MYI 100% 16KB 6.9MB/s 00:00 help_keyword.MYD 100% 89KB 35.1MB/s 00:00 time_zone_name.frm 100% 8606 4.3MB/s 00:00 time_zone_name.MYI 100% 1024 659.9KB/s 00:00 time_zone_name.MYD 100% 0 0.0KB/s 00:00 time_zone.frm 100% 8636 4.7MB/s 00:00 time_zone.MYI 100% 1024 772.0KB/s 00:00 time_zone.MYD 100% 0 0.0KB/s 00:00 time_zone_transition.frm 100% 8686 6.1MB/s 00:00 time_zone_transition.MYI 100% 1024 1.2MB/s 00:00 time_zone_transition.MYD 100% 0 0.0KB/s 00:00 time_zone_transition_type.frm 100% 8748 5.6MB/s 00:00 time_zone_transition_type.MYI 100% 1024 714.8KB/s 00:00 time_zone_transition_type.MYD 100% 0 0.0KB/s 00:00 time_zone_leap_second.frm 100% 8624 7.0MB/s 00:00 time_zone_leap_second.MYI 100% 1024 788.2KB/s 00:00 time_zone_leap_second.MYD 100% 0 0.0KB/s 00:00 proc.frm 100% 10KB 5.8MB/s 00:00 proc.MYI 100% 4096 3.3MB/s 00:00 proc.MYD 100% 292 246.5KB/s 00:00 procs_priv.frm 100% 8875 4.6MB/s 00:00 procs_priv.MYI 100% 4096 3.4MB/s 00:00 procs_priv.MYD 100% 0 0.0KB/s 00:00 general_log.frm 100% 8776 4.1MB/s 00:00 general_log.CSM 100% 35 28.4KB/s 00:00 general_log.CSV 100% 0 0.0KB/s 00:00 slow_log.frm 100% 8976 7.5MB/s 00:00 slow_log.CSM 100% 35 23.5KB/s 00:00 slow_log.CSV 100% 0 0.0KB/s 00:00 event.frm 100% 10KB 3.8MB/s 00:00 event.MYI 100% 2048 1.6MB/s 00:00 event.MYD 100% 0 0.0KB/s 00:00 ndb_binlog_index.frm 100% 8778 7.1MB/s 00:00 ndb_binlog_index.MYI 100% 1024 656.8KB/s 00:00 ndb_binlog_index.MYD 100% 0 0.0KB/s 00:00 proxies_priv.frm 100% 8800 7.5MB/s 00:00 proxies_priv.MYI 100% 5120 4.9MB/s 00:00 proxies_priv.MYD 100% 1386 1.0MB/s 00:00 db.opt 100% 0 0.0KB/s 00:00 db.opt 100% 61 35.3KB/s 00:00 cond_instances.frm 100% 8624 6.9MB/s 00:00 events_waits_current.frm 100% 9220 7.8MB/s 00:00 events_waits_history.frm 100% 9220 5.8MB/s 00:00 events_waits_history_long.frm 100% 9220 6.7MB/s 00:00 events_waits_summary_by_instance.frm 100% 8878 5.0MB/s 00:00 events_waits_summary_by_thread_by_event_nam 100% 8854 5.5MB/s 00:00 events_waits_summary_global_by_event_name.f 100% 8814 3.3MB/s 00:00 file_instances.frm 100% 8654 5.2MB/s 00:00 file_summary_by_event_name.frm 100% 8800 4.3MB/s 00:00 file_summary_by_instance.frm 100% 8840 6.2MB/s 00:00 mutex_instances.frm 100% 8684 4.2MB/s 00:00 performance_timers.frm 100% 8776 7.1MB/s 00:00 rwlock_instances.frm 100% 8758 4.5MB/s 00:00 setup_consumers.frm 100% 8605 5.0MB/s 00:00 setup_instruments.frm 100% 8637 7.9MB/s 00:00 setup_timers.frm 100% 8650 7.8MB/s 00:00 threads.frm 100% 8650 6.3MB/s 00:00 db.opt 100% 61 37.6KB/s 00:00 classes.frm 100% 8636 5.8MB/s 00:00 coc.frm 100% 8630 4.2MB/s 00:00 courses.frm 100% 8602 4.6MB/s 00:00 scores.frm 100% 8658 6.2MB/s 00:00 students.frm 100% 8736 6.6MB/s 00:00 teachers.frm 100% 8656 5.4MB/s 00:00 toc.frm 100% 8622 6.7MB/s 00:00 xtrabackup_checkpoints 100% 113 65.1KB/s 00:00 backup-my.cnf 100% 431 356.9KB/s 00:00 xtrabackup_info 100% 424 255.8KB/s 00:00 [root@Centos7 ~]#
[root@Centos7 ~]#xtrabackup --prepare --target-dir=/data/backup xtrabackup: recognized server arguments: --innodb_checksum_algorithm=innodb --innodb_log_checksum_algorithm=innodb --innodb_data_file_path=ibdata1:10M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=5242880 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=. --innodb_undo_tablespaces=0 --server-id=0 --redo-log-version=0 xtrabackup: recognized client arguments: --innodb_checksum_algorithm=innodb --innodb_log_checksum_algorithm=innodb --innodb_data_file_path=ibdata1:10M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=5242880 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=. --innodb_undo_tablespaces=0 --server-id=0 --redo-log-version=0 --prepare=1 --target-dir=/data/backup xtrabackup version 2.4.13 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 3e7ca7c) xtrabackup: cd to /data/backup/ xtrabackup: This target seems to be not prepared yet. InnoDB: Number of pools: 1 xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(1628321) xtrabackup: using the following InnoDB configuration for recovery: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend xtrabackup: innodb_log_group_home_dir = . xtrabackup: innodb_log_files_in_group = 1 xtrabackup: innodb_log_file_size = 8388608 xtrabackup: using the following InnoDB configuration for recovery: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend xtrabackup: innodb_log_group_home_dir = . xtrabackup: innodb_log_files_in_group = 1 xtrabackup: innodb_log_file_size = 8388608 xtrabackup: Starting InnoDB instance for recovery. xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) InnoDB: PUNCH HOLE support available InnoDB: Mutexes and rw_locks use GCC atomic builtins InnoDB: Uses event mutexes InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier InnoDB: Compressed tables use zlib 1.2.7 InnoDB: Number of pools: 1 InnoDB: Using CPU crc32 instructions InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M InnoDB: Completed initialization of buffer pool InnoDB: page_cleaner coordinator priority: -20 InnoDB: Highest supported file format is Barracuda. InnoDB: The log sequence number 0 in the system tablespace does not match the log sequence number 1628321 in the ib_logfiles! InnoDB: Database was not shutdown normally! InnoDB: Starting crash recovery. InnoDB: Creating shared tablespace for temporary tables InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... InnoDB: File './ibtmp1' size is now 12 MB. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active. InnoDB: 32 non-redo rollback segment(s) are active. InnoDB: 5.7.19 started; log sequence number 1628321
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1628340
InnoDB: Number of pools: 1
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = .
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 5242880
InnoDB: PUNCH HOLE support available
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Uses event mutexes
InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
InnoDB: Compressed tables use zlib 1.2.7
InnoDB: Number of pools: 1
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
InnoDB: Completed initialization of buffer pool
InnoDB: page_cleaner coordinator priority: -20
InnoDB: Setting log file ./ib_logfile101 size to 5 MB
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
InnoDB: New log files created, LSN=1628340
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 1628684
InnoDB: Doing recovery: scanned up to log sequence number 1628693 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: Removed temporary tablespace data file: "ibtmp1"
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: 5.7.19 started; log sequence number 1628693
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1628712
190508 11:49:11 completed OK!
- 複製到數據庫目錄:xtrabackup --copy-back --target-dir=/data/backup 要求數據庫目錄必須爲空,MySQL服務不能啓動 ```bash [root@Centos7 ~]#xtrabackup --copy-back --target-dir=/data/backup xtrabackup: recognized server arguments: --datadir=/var/lib/mysql xtrabackup: recognized client arguments: --datadir=/var/lib/mysql --copy-back=1 --target-dir=/data/backup xtrabackup version 2.4.13 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 3e7ca7c) 190508 11:57:47 [01] Copying ib_logfile0 to /var/lib/mysql/ib_logfile0 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ib_logfile1 to /var/lib/mysql/ib_logfile1 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ibdata1 to /var/lib/mysql/ibdata1 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/db.frm to /var/lib/mysql/mysql/db.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/db.MYI to /var/lib/mysql/mysql/db.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/db.MYD to /var/lib/mysql/mysql/db.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/host.frm to /var/lib/mysql/mysql/host.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/host.MYI to /var/lib/mysql/mysql/host.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/host.MYD to /var/lib/mysql/mysql/host.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/user.frm to /var/lib/mysql/mysql/user.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/user.MYI to /var/lib/mysql/mysql/user.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/user.MYD to /var/lib/mysql/mysql/user.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/func.frm to /var/lib/mysql/mysql/func.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/func.MYI to /var/lib/mysql/mysql/func.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/func.MYD to /var/lib/mysql/mysql/func.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/plugin.frm to /var/lib/mysql/mysql/plugin.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/plugin.MYI to /var/lib/mysql/mysql/plugin.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/plugin.MYD to /var/lib/mysql/mysql/plugin.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/servers.frm to /var/lib/mysql/mysql/servers.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/servers.MYI to /var/lib/mysql/mysql/servers.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/servers.MYD to /var/lib/mysql/mysql/servers.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/tables_priv.frm to /var/lib/mysql/mysql/tables_priv.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/tables_priv.MYI to /var/lib/mysql/mysql/tables_priv.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/tables_priv.MYD to /var/lib/mysql/mysql/tables_priv.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/columns_priv.frm to /var/lib/mysql/mysql/columns_priv.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/columns_priv.MYI to /var/lib/mysql/mysql/columns_priv.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/columns_priv.MYD to /var/lib/mysql/mysql/columns_priv.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_topic.frm to /var/lib/mysql/mysql/help_topic.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_topic.MYI to /var/lib/mysql/mysql/help_topic.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_topic.MYD to /var/lib/mysql/mysql/help_topic.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_category.frm to /var/lib/mysql/mysql/help_category.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_category.MYI to /var/lib/mysql/mysql/help_category.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_category.MYD to /var/lib/mysql/mysql/help_category.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_relation.frm to /var/lib/mysql/mysql/help_relation.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_relation.MYI to /var/lib/mysql/mysql/help_relation.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_relation.MYD to /var/lib/mysql/mysql/help_relation.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_keyword.frm to /var/lib/mysql/mysql/help_keyword.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_keyword.MYI to /var/lib/mysql/mysql/help_keyword.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/help_keyword.MYD to /var/lib/mysql/mysql/help_keyword.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_name.frm to /var/lib/mysql/mysql/time_zone_name.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_name.MYI to /var/lib/mysql/mysql/time_zone_name.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_name.MYD to /var/lib/mysql/mysql/time_zone_name.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone.frm to /var/lib/mysql/mysql/time_zone.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone.MYI to /var/lib/mysql/mysql/time_zone.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone.MYD to /var/lib/mysql/mysql/time_zone.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition.frm to /var/lib/mysql/mysql/time_zone_transition.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition.MYI to /var/lib/mysql/mysql/time_zone_transition.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition.MYD to /var/lib/mysql/mysql/time_zone_transition.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition_type.frm to /var/lib/mysql/mysql/time_zone_transition_type.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition_type.MYI to /var/lib/mysql/mysql/time_zone_transition_type.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_transition_type.MYD to /var/lib/mysql/mysql/time_zone_transition_type.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_leap_second.frm to /var/lib/mysql/mysql/time_zone_leap_second.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_leap_second.MYI to /var/lib/mysql/mysql/time_zone_leap_second.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/time_zone_leap_second.MYD to /var/lib/mysql/mysql/time_zone_leap_second.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proc.frm to /var/lib/mysql/mysql/proc.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proc.MYI to /var/lib/mysql/mysql/proc.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proc.MYD to /var/lib/mysql/mysql/proc.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/procs_priv.frm to /var/lib/mysql/mysql/procs_priv.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/procs_priv.MYI to /var/lib/mysql/mysql/procs_priv.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/procs_priv.MYD to /var/lib/mysql/mysql/procs_priv.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/general_log.frm to /var/lib/mysql/mysql/general_log.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/general_log.CSM to /var/lib/mysql/mysql/general_log.CSM 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/general_log.CSV to /var/lib/mysql/mysql/general_log.CSV 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/slow_log.frm to /var/lib/mysql/mysql/slow_log.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/slow_log.CSM to /var/lib/mysql/mysql/slow_log.CSM 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/slow_log.CSV to /var/lib/mysql/mysql/slow_log.CSV 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/event.frm to /var/lib/mysql/mysql/event.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/event.MYI to /var/lib/mysql/mysql/event.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/event.MYD to /var/lib/mysql/mysql/event.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/ndb_binlog_index.frm to /var/lib/mysql/mysql/ndb_binlog_index.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/ndb_binlog_index.MYI to /var/lib/mysql/mysql/ndb_binlog_index.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/ndb_binlog_index.MYD to /var/lib/mysql/mysql/ndb_binlog_index.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proxies_priv.frm to /var/lib/mysql/mysql/proxies_priv.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proxies_priv.MYI to /var/lib/mysql/mysql/proxies_priv.MYI 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./mysql/proxies_priv.MYD to /var/lib/mysql/mysql/proxies_priv.MYD 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./test/db.opt to /var/lib/mysql/test/db.opt 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/db.opt to /var/lib/mysql/performance_schema/db.opt 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/cond_instances.frm to /var/lib/mysql/performance_schema/cond_instances.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/events_waits_current.frm to /var/lib/mysql/performance_schema/events_waits_current.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/events_waits_history.frm to /var/lib/mysql/performance_schema/events_waits_history.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/events_waits_history_long.frm to /var/lib/mysql/performance_schema/events_waits_history_long.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_instance.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./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 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_global_by_event_name.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/file_instances.frm to /var/lib/mysql/performance_schema/file_instances.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /var/lib/mysql/performance_schema/file_summary_by_event_name.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/file_summary_by_instance.frm to /var/lib/mysql/performance_schema/file_summary_by_instance.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/mutex_instances.frm to /var/lib/mysql/performance_schema/mutex_instances.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/performance_timers.frm to /var/lib/mysql/performance_schema/performance_timers.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/rwlock_instances.frm to /var/lib/mysql/performance_schema/rwlock_instances.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/setup_consumers.frm to /var/lib/mysql/performance_schema/setup_consumers.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/setup_instruments.frm to /var/lib/mysql/performance_schema/setup_instruments.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/setup_timers.frm to /var/lib/mysql/performance_schema/setup_timers.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./performance_schema/threads.frm to /var/lib/mysql/performance_schema/threads.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/db.opt to /var/lib/mysql/hellodb/db.opt 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/classes.frm to /var/lib/mysql/hellodb/classes.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/coc.frm to /var/lib/mysql/hellodb/coc.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/courses.frm to /var/lib/mysql/hellodb/courses.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/scores.frm to /var/lib/mysql/hellodb/scores.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/students.frm to /var/lib/mysql/hellodb/students.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/teachers.frm to /var/lib/mysql/hellodb/teachers.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./hellodb/toc.frm to /var/lib/mysql/hellodb/toc.frm 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./xtrabackup_master_key_id to /var/lib/mysql/xtrabackup_master_key_id 190508 11:57:47 [01] ...done 190508 11:57:47 [01] Copying ./ibtmp1 to /var/lib/mysql/ibtmp1 190508 11:57:48 [01] ...done 190508 11:57:48 completed OK!
[root@Centos7 ~]#chown -R mysql.mysql /var/lib/mysql [root@Centos7 ~]#systemctl start mariadb [root@Centos7 ~]#mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hellodb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.01 sec)
MariaDB [(none)]> quit
Bye
[root@Centos7 ~]#
數據已還原到新主機上 - 增量備份還原 測試 在原主機數據庫中增長一條記錄,測試增量備份 ```bash [root@Centos7 ~]#mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 5.5.60-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> inster teacher (name,age)value('lisi',18); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'inster teacher (name,age)value('lisi',18)' at line 1 MariaDB [(none)]> inster hellodb.teachers (name,age)value('lisi',18); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'inster hellodb.teachers (name,age)value('lisi',18)' at line 1 MariaDB [(none)]> use hellodb 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 MariaDB [hellodb]> show tables; +-------------------+ | Tables_in_hellodb | +-------------------+ | classes | | coc | | courses | | scores | | students | | teachers | | toc | +-------------------+ 7 rows in set (0.00 sec) MariaDB [hellodb]> insert teachers (name,age)value('lisi',18); Query OK, 1 row affected (0.02 sec) MariaDB [hellodb]>
第一次增備份
xtrabackup --backup --target-dir=/data/inc1 --incremenal-basedir=/data/backup
[root@Centos7 ~]#xtrabackup --backup --target-dir=/data/inc1 --incremenal-basedir=/data/backup xtrabackup: recognized server arguments: --datadir=/var/lib/mysql xtrabackup: recognized client arguments: --datadir=/var/lib/mysql --backup=1 --target-dir=/data/inc1 190508 12:11:59 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' (using password: NO). 190508 12:11:59 version_check Connected to MySQL server 190508 12:11:59 version_check Executing a version check against the server... 190508 12:11:59 version_check Done. 190508 12:11:59 Connecting to MySQL server host: localhost, user: not set, password: not set, port: not set, socket: not set Using server version 5.5.60-MariaDB xtrabackup version 2.4.13 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 3e7ca7c) 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:10M:autoextend xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 2 xtrabackup: innodb_log_file_size = 5242880 InnoDB: Number of pools: 1 190508 12:11:59 >> log scanned up to (1629159) xtrabackup: Generating a list of tablespaces 190508 12:11:59 [01] Copying ./ibdata1 to /data/inc1/ibdata1 190508 12:11:59 [01] ...done 190508 12:12:00 >> log scanned up to (1629159) 190508 12:12:00 Executing FLUSH NO_WRITE_TO_BINLOG TABLES... 190508 12:12:00 Executing FLUSH TABLES WITH READ LOCK... 190508 12:12:00 Starting to backup non-InnoDB tables and files 190508 12:12:00 [01] Copying ./mysql/db.frm to /data/inc1/mysql/db.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/db.MYI to /data/inc1/mysql/db.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/db.MYD to /data/inc1/mysql/db.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/host.frm to /data/inc1/mysql/host.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/host.MYI to /data/inc1/mysql/host.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/host.MYD to /data/inc1/mysql/host.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/user.frm to /data/inc1/mysql/user.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/user.MYI to /data/inc1/mysql/user.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/user.MYD to /data/inc1/mysql/user.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/func.frm to /data/inc1/mysql/func.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/func.MYI to /data/inc1/mysql/func.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/func.MYD to /data/inc1/mysql/func.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/plugin.frm to /data/inc1/mysql/plugin.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/plugin.MYI to /data/inc1/mysql/plugin.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/plugin.MYD to /data/inc1/mysql/plugin.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/servers.frm to /data/inc1/mysql/servers.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/servers.MYI to /data/inc1/mysql/servers.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/servers.MYD to /data/inc1/mysql/servers.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/tables_priv.frm to /data/inc1/mysql/tables_priv.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/tables_priv.MYI to /data/inc1/mysql/tables_priv.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/tables_priv.MYD to /data/inc1/mysql/tables_priv.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/columns_priv.frm to /data/inc1/mysql/columns_priv.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/columns_priv.MYI to /data/inc1/mysql/columns_priv.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/columns_priv.MYD to /data/inc1/mysql/columns_priv.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_topic.frm to /data/inc1/mysql/help_topic.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_topic.MYI to /data/inc1/mysql/help_topic.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_topic.MYD to /data/inc1/mysql/help_topic.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_category.frm to /data/inc1/mysql/help_category.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_category.MYI to /data/inc1/mysql/help_category.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_category.MYD to /data/inc1/mysql/help_category.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_relation.frm to /data/inc1/mysql/help_relation.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_relation.MYI to /data/inc1/mysql/help_relation.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_relation.MYD to /data/inc1/mysql/help_relation.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_keyword.frm to /data/inc1/mysql/help_keyword.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_keyword.MYI to /data/inc1/mysql/help_keyword.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/help_keyword.MYD to /data/inc1/mysql/help_keyword.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_name.frm to /data/inc1/mysql/time_zone_name.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_name.MYI to /data/inc1/mysql/time_zone_name.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_name.MYD to /data/inc1/mysql/time_zone_name.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone.frm to /data/inc1/mysql/time_zone.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone.MYI to /data/inc1/mysql/time_zone.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone.MYD to /data/inc1/mysql/time_zone.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition.frm to /data/inc1/mysql/time_zone_transition.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition.MYI to /data/inc1/mysql/time_zone_transition.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition.MYD to /data/inc1/mysql/time_zone_transition.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition_type.frm to /data/inc1/mysql/time_zone_transition_type.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition_type.MYI to /data/inc1/mysql/time_zone_transition_type.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_transition_type.MYD to /data/inc1/mysql/time_zone_transition_type.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_leap_second.frm to /data/inc1/mysql/time_zone_leap_second.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_leap_second.MYI to /data/inc1/mysql/time_zone_leap_second.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/time_zone_leap_second.MYD to /data/inc1/mysql/time_zone_leap_second.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proc.frm to /data/inc1/mysql/proc.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proc.MYI to /data/inc1/mysql/proc.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proc.MYD to /data/inc1/mysql/proc.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/procs_priv.frm to /data/inc1/mysql/procs_priv.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/procs_priv.MYI to /data/inc1/mysql/procs_priv.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/procs_priv.MYD to /data/inc1/mysql/procs_priv.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/general_log.frm to /data/inc1/mysql/general_log.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/general_log.CSM to /data/inc1/mysql/general_log.CSM 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/general_log.CSV to /data/inc1/mysql/general_log.CSV 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/slow_log.frm to /data/inc1/mysql/slow_log.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/slow_log.CSM to /data/inc1/mysql/slow_log.CSM 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/slow_log.CSV to /data/inc1/mysql/slow_log.CSV 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/event.frm to /data/inc1/mysql/event.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/event.MYI to /data/inc1/mysql/event.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/event.MYD to /data/inc1/mysql/event.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/ndb_binlog_index.frm to /data/inc1/mysql/ndb_binlog_index.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/ndb_binlog_index.MYI to /data/inc1/mysql/ndb_binlog_index.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/ndb_binlog_index.MYD to /data/inc1/mysql/ndb_binlog_index.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proxies_priv.frm to /data/inc1/mysql/proxies_priv.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proxies_priv.MYI to /data/inc1/mysql/proxies_priv.MYI 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./mysql/proxies_priv.MYD to /data/inc1/mysql/proxies_priv.MYD 190508 12:12:00 [01] ...done 190508 12:12:00 [00] Writing /data/inc1/test/db.opt 190508 12:12:00 [00] ...done 190508 12:12:00 [01] Copying ./performance_schema/db.opt to /data/inc1/performance_schema/db.opt 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/cond_instances.frm to /data/inc1/performance_schema/cond_instances.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_current.frm to /data/inc1/performance_schema/events_waits_current.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_history.frm to /data/inc1/performance_schema/events_waits_history.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_history_long.frm to /data/inc1/performance_schema/events_waits_history_long.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /data/inc1/performance_schema/events_waits_summary_by_instance.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /data/inc1/performance_schema/events_waits_summary_by_thread_by_event_name.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /data/inc1/performance_schema/events_waits_summary_global_by_event_name.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/file_instances.frm to /data/inc1/performance_schema/file_instances.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /data/inc1/performance_schema/file_summary_by_event_name.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/file_summary_by_instance.frm to /data/inc1/performance_schema/file_summary_by_instance.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/mutex_instances.frm to /data/inc1/performance_schema/mutex_instances.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/performance_timers.frm to /data/inc1/performance_schema/performance_timers.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/rwlock_instances.frm to /data/inc1/performance_schema/rwlock_instances.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/setup_consumers.frm to /data/inc1/performance_schema/setup_consumers.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/setup_instruments.frm to /data/inc1/performance_schema/setup_instruments.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/setup_timers.frm to /data/inc1/performance_schema/setup_timers.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./performance_schema/threads.frm to /data/inc1/performance_schema/threads.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/db.opt to /data/inc1/hellodb/db.opt 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/classes.frm to /data/inc1/hellodb/classes.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/coc.frm to /data/inc1/hellodb/coc.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/courses.frm to /data/inc1/hellodb/courses.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/scores.frm to /data/inc1/hellodb/scores.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/students.frm to /data/inc1/hellodb/students.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/teachers.frm to /data/inc1/hellodb/teachers.frm 190508 12:12:00 [01] ...done 190508 12:12:00 [01] Copying ./hellodb/toc.frm to /data/inc1/hellodb/toc.frm 190508 12:12:00 [01] ...done 190508 12:12:00 Finished backing up non-InnoDB tables and files 190508 12:12:00 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point (for incremental): '1629159' xtrabackup: Stopping log copying thread. .190508 12:12:00 >> log scanned up to (1629159) 190508 12:12:01 Executing UNLOCK TABLES 190508 12:12:01 All tables unlocked 190508 12:12:01 Backup created in directory '/data/inc1/' 190508 12:12:01 [00] Writing /data/inc1/backup-my.cnf 190508 12:12:01 [00] ...done 190508 12:12:01 [00] Writing /data/inc1/xtrabackup_info 190508 12:12:01 [00] ...done xtrabackup: Transaction log of lsn (1629159) to (1629159) was copied. 190508 12:12:01 completed OK!
再添加一條記錄,測試第二次增量備份
xtrabackup --backup --target-dir=/data/inc2 --incremenal-basedir=/data/inc1
在目標主機還原數據