1.[root@mysql-master ~]#yum install percona-xtrabackup -y
create database test;
use test;
create table bak(id int ,name char(20)); 创建表
insert into bak values(1,'dog');
MariaDB [(none)]> grant reload,lock tables,replication client on *.* to 'bakupuser'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
root@mysql-master ~]#innobackupex --user=bakupuser --password=123456 /backup/
171227 19:56:21 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!".
Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 693.
BEGIN failed--compilation aborted at - line 693.
171227 19:56:22 Connecting to MySQL server host: localhost, user: bakupuser, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.5.52-MariaDB
innobackupex version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
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
171227 19:56:22 >> log scanned up to (1602621)
xtrabackup: Generating a list of tablespaces
171227 19:56:22 [01] Copying ./ibdata1 to /backup//2017-12-27_19-56-21/ibdata1
171227 19:56:23 >> log scanned up to (1602621)
171227 19:56:23 [01] ...done
171227 19:56:24 >> log scanned up to (1602621)
171227 19:56:24 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
171227 19:56:24 Executing FLUSH TABLES WITH READ LOCK...
171227 19:56:24 Starting to backup non-InnoDB tables and files
171227 19:56:24 [01] Copying ./mysql/db.frm to /backup//2017-12-27_19-56-21/mysql/db.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/db.MYI to /backup//2017-12-27_19-56-21/mysql/db.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/db.MYD to /backup//2017-12-27_19-56-21/mysql/db.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/host.frm to /backup//2017-12-27_19-56-21/mysql/host.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/host.MYI to /backup//2017-12-27_19-56-21/mysql/host.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/host.MYD to /backup//2017-12-27_19-56-21/mysql/host.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/user.frm to /backup//2017-12-27_19-56-21/mysql/user.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/user.MYI to /backup//2017-12-27_19-56-21/mysql/user.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/user.MYD to /backup//2017-12-27_19-56-21/mysql/user.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/func.frm to /backup//2017-12-27_19-56-21/mysql/func.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/func.MYI to /backup//2017-12-27_19-56-21/mysql/func.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/func.MYD to /backup//2017-12-27_19-56-21/mysql/func.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/plugin.frm to /backup//2017-12-27_19-56-21/mysql/plugin.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/plugin.MYI to /backup//2017-12-27_19-56-21/mysql/plugin.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/plugin.MYD to /backup//2017-12-27_19-56-21/mysql/plugin.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/servers.frm to /backup//2017-12-27_19-56-21/mysql/servers.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/servers.MYI to /backup//2017-12-27_19-56-21/mysql/servers.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/servers.MYD to /backup//2017-12-27_19-56-21/mysql/servers.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/tables_priv.frm to /backup//2017-12-27_19-56-21/mysql/tables_priv.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/tables_priv.MYI to /backup//2017-12-27_19-56-21/mysql/tables_priv.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/tables_priv.MYD to /backup//2017-12-27_19-56-21/mysql/tables_priv.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/columns_priv.frm to /backup//2017-12-27_19-56-21/mysql/columns_priv.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/columns_priv.MYI to /backup//2017-12-27_19-56-21/mysql/columns_priv.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/columns_priv.MYD to /backup//2017-12-27_19-56-21/mysql/columns_priv.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_topic.frm to /backup//2017-12-27_19-56-21/mysql/help_topic.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_topic.MYI to /backup//2017-12-27_19-56-21/mysql/help_topic.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_topic.MYD to /backup//2017-12-27_19-56-21/mysql/help_topic.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_category.frm to /backup//2017-12-27_19-56-21/mysql/help_category.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_category.MYI to /backup//2017-12-27_19-56-21/mysql/help_category.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_category.MYD to /backup//2017-12-27_19-56-21/mysql/help_category.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_relation.frm to /backup//2017-12-27_19-56-21/mysql/help_relation.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_relation.MYI to /backup//2017-12-27_19-56-21/mysql/help_relation.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_relation.MYD to /backup//2017-12-27_19-56-21/mysql/help_relation.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_keyword.frm to /backup//2017-12-27_19-56-21/mysql/help_keyword.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_keyword.MYI to /backup//2017-12-27_19-56-21/mysql/help_keyword.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/help_keyword.MYD to /backup//2017-12-27_19-56-21/mysql/help_keyword.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_name.frm to /backup//2017-12-27_19-56-21/mysql/time_zone_name.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_name.MYI to /backup//2017-12-27_19-56-21/mysql/time_zone_name.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_name.MYD to /backup//2017-12-27_19-56-21/mysql/time_zone_name.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone.frm to /backup//2017-12-27_19-56-21/mysql/time_zone.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone.MYI to /backup//2017-12-27_19-56-21/mysql/time_zone.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone.MYD to /backup//2017-12-27_19-56-21/mysql/time_zone.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition.frm to /backup//2017-12-27_19-56-21/mysql/time_zone_transition.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition.MYI to /backup//2017-12-27_19-56-21/mysql/time_zone_transition.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition.MYD to /backup//2017-12-27_19-56-21/mysql/time_zone_transition.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition_type.frm to /backup//2017-12-27_19-56-21/mysql/time_zone_transition_type.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition_type.MYI to /backup//2017-12-27_19-56-21/mysql/time_zone_transition_type.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_transition_type.MYD to /backup//2017-12-27_19-56-21/mysql/time_zone_transition_type.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_leap_second.frm to /backup//2017-12-27_19-56-21/mysql/time_zone_leap_second.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_leap_second.MYI to /backup//2017-12-27_19-56-21/mysql/time_zone_leap_second.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/time_zone_leap_second.MYD to /backup//2017-12-27_19-56-21/mysql/time_zone_leap_second.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proc.frm to /backup//2017-12-27_19-56-21/mysql/proc.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proc.MYI to /backup//2017-12-27_19-56-21/mysql/proc.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proc.MYD to /backup//2017-12-27_19-56-21/mysql/proc.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/procs_priv.frm to /backup//2017-12-27_19-56-21/mysql/procs_priv.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/procs_priv.MYI to /backup//2017-12-27_19-56-21/mysql/procs_priv.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/procs_priv.MYD to /backup//2017-12-27_19-56-21/mysql/procs_priv.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/general_log.frm to /backup//2017-12-27_19-56-21/mysql/general_log.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/general_log.CSM to /backup//2017-12-27_19-56-21/mysql/general_log.CSM
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/general_log.CSV to /backup//2017-12-27_19-56-21/mysql/general_log.CSV
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/slow_log.frm to /backup//2017-12-27_19-56-21/mysql/slow_log.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/slow_log.CSM to /backup//2017-12-27_19-56-21/mysql/slow_log.CSM
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/slow_log.CSV to /backup//2017-12-27_19-56-21/mysql/slow_log.CSV
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/event.frm to /backup//2017-12-27_19-56-21/mysql/event.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/event.MYI to /backup//2017-12-27_19-56-21/mysql/event.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/event.MYD to /backup//2017-12-27_19-56-21/mysql/event.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/ndb_binlog_index.frm to /backup//2017-12-27_19-56-21/mysql/ndb_binlog_index.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/ndb_binlog_index.MYI to /backup//2017-12-27_19-56-21/mysql/ndb_binlog_index.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/ndb_binlog_index.MYD to /backup//2017-12-27_19-56-21/mysql/ndb_binlog_index.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proxies_priv.frm to /backup//2017-12-27_19-56-21/mysql/proxies_priv.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proxies_priv.MYI to /backup//2017-12-27_19-56-21/mysql/proxies_priv.MYI
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./mysql/proxies_priv.MYD to /backup//2017-12-27_19-56-21/mysql/proxies_priv.MYD
171227 19:56:24 [01] ...done
171227 19:56:24 [00] Writing test/db.opt
171227 19:56:24 [00] ...done
171227 19:56:24 [01] Copying ./performance_schema/db.opt to /backup//2017-12-27_19-56-21/performance_schema/db.opt
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/cond_instances.frm to /backup//2017-12-27_19-56-21/performance_schema/cond_instances.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_current.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_current.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_history.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_history.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_history_long.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_history_long.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_summary_by_instance.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_summary_by_thread_by_event_name.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /backup//2017-12-27_19-56-21/performance_schema/events_waits_summary_global_by_event_name.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/file_instances.frm to /backup//2017-12-27_19-56-21/performance_schema/file_instances.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /backup//2017-12-27_19-56-21/performance_schema/file_summary_by_event_name.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/file_summary_by_instance.frm to /backup//2017-12-27_19-56-21/performance_schema/file_summary_by_instance.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/mutex_instances.frm to /backup//2017-12-27_19-56-21/performance_schema/mutex_instances.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/performance_timers.frm to /backup//2017-12-27_19-56-21/performance_schema/performance_timers.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/rwlock_instances.frm to /backup//2017-12-27_19-56-21/performance_schema/rwlock_instances.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/setup_consumers.frm to /backup//2017-12-27_19-56-21/performance_schema/setup_consumers.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/setup_instruments.frm to /backup//2017-12-27_19-56-21/performance_schema/setup_instruments.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/setup_timers.frm to /backup//2017-12-27_19-56-21/performance_schema/setup_timers.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./performance_schema/threads.frm to /backup//2017-12-27_19-56-21/performance_schema/threads.frm
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./class/db.opt to /backup//2017-12-27_19-56-21/class/db.opt
171227 19:56:24 [01] ...done
171227 19:56:24 [01] Copying ./class/tb.frm to /backup//2017-12-27_19-56-21/class/tb.frm
171227 19:56:25 [01] ...done
171227 19:56:25 [01] Copying ./test1/db.opt to /backup//2017-12-27_19-56-21/test1/db.opt
171227 19:56:25 [01] ...done
171227 19:56:25 [01] Copying ./test1/course.frm to /backup//2017-12-27_19-56-21/test1/course.frm
171227 19:56:25 [01] ...done
171227 19:56:25 Finished backing up non-InnoDB tables and files
171227 19:56:25 [00] Writing xtrabackup_binlog_info
171227 19:56:25 [00] ...done
171227 19:56:25 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '1602621'
xtrabackup: Stopping log copying thread.
.171227 19:56:25 >> log scanned up to (1602621)
171227 19:56:25 Executing UNLOCK TABLES
171227 19:56:25 All tables unlocked
171227 19:56:25 Backup created in directory '/backup//2017-12-27_19-56-21'
MySQL binlog position: filename 'mysql-bin.000005', position '812'
171227 19:56:25 [00] Writing backup-my.cnf
171227 19:56:25 [00] ...done
171227 19:56:25 [00] Writing xtrabackup_info
171227 19:56:25 [00] ...done
xtrabackup: Transaction log of lsn (1602621) to (1602621) was copied.
171227 19:56:25 completed OK!
[rootredis-master01 ~]# ls /backup/
2017-12-27_19-56-21
[rootmysql-master1 ~]# cd /backup/2017-12-27_19-56-21/ 注:下面增量备份的东西就放在此目录下
[rootmysql-master1 2017-12-27_19-56-21]# ls
backup-my.cnf ibdata1 performance_schema test1 xtrabackup_checkpoints xtrabackup_logfile
class mysql test xtrabackup_binlog_info xtrabackup_info
[rootmysql-master1 ~]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> insert into test1.course values(002,'linux');
Query OK, 1 row affected (0.21 sec)
MariaDB [(none)]> select * from test1.course;
+------+-------+
| id | name |
+------+-------+
| 1 | math |
| 2 | linux |
+------+-------+
2 rows in set (0.00 sec)
MariaDB [(none)]> exit;
Bye
[rootmysql-master1 ~]# innobackupex --incremental /backup/ --incremental-basedir=/backup/2017-12-27_19-56-21/ 注:此目录为全量备份所在目录,也即指明在哪的基础上进行增量备份
171227 20:05:28 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!".
Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 693.
BEGIN failed--compilation aborted at - line 693.
171227 20:05:28 Connecting to MySQL server host: localhost, user: (null), password: not set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.5.52-MariaDB
innobackupex version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
incremental backup from 1602621 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:10M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 5242880
171227 20:05:28 >> log scanned up to (1603665)
xtrabackup: Generating a list of tablespaces
xtrabackup: using the full scan for incremental backup
171227 20:05:29 [01] Copying ./ibdata1 to /backup//2017-12-27_20-05-28/ibdata1.delta
171227 20:05:29 [01] ...done
171227 20:05:29 >> log scanned up to (1603665)
171227 20:05:29 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
171227 20:05:29 Executing FLUSH TABLES WITH READ LOCK...
171227 20:05:29 Starting to backup non-InnoDB tables and files
171227 20:05:29 [01] Copying ./mysql/db.frm to /backup//2017-12-27_20-05-28/mysql/db.frm
171227 20:05:29 [01] ...done
171227 20:05:29 [01] Copying ./mysql/db.MYI to /backup//2017-12-27_20-05-28/mysql/db.MYI
171227 20:05:29 [01] ...done
171227 20:05:29 [01] Copying ./mysql/db.MYD to /backup//2017-12-27_20-05-28/mysql/db.MYD
171227 20:05:29 [01] ...done
171227 20:05:29 [01] Copying ./mysql/host.frm to /backup//2017-12-27_20-05-28/mysql/host.frm
171227 20:05:29 [01] ...done
171227 20:05:29 [01] Copying ./mysql/host.MYI to /backup//2017-12-27_20-05-28/mysql/host.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/host.MYD to /backup//2017-12-27_20-05-28/mysql/host.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/user.frm to /backup//2017-12-27_20-05-28/mysql/user.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/user.MYI to /backup//2017-12-27_20-05-28/mysql/user.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/user.MYD to /backup//2017-12-27_20-05-28/mysql/user.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/func.frm to /backup//2017-12-27_20-05-28/mysql/func.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/func.MYI to /backup//2017-12-27_20-05-28/mysql/func.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/func.MYD to /backup//2017-12-27_20-05-28/mysql/func.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/plugin.frm to /backup//2017-12-27_20-05-28/mysql/plugin.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/plugin.MYI to /backup//2017-12-27_20-05-28/mysql/plugin.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/plugin.MYD to /backup//2017-12-27_20-05-28/mysql/plugin.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/servers.frm to /backup//2017-12-27_20-05-28/mysql/servers.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/servers.MYI to /backup//2017-12-27_20-05-28/mysql/servers.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/servers.MYD to /backup//2017-12-27_20-05-28/mysql/servers.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/tables_priv.frm to /backup//2017-12-27_20-05-28/mysql/tables_priv.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/tables_priv.MYI to /backup//2017-12-27_20-05-28/mysql/tables_priv.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/tables_priv.MYD to /backup//2017-12-27_20-05-28/mysql/tables_priv.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/columns_priv.frm to /backup//2017-12-27_20-05-28/mysql/columns_priv.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/columns_priv.MYI to /backup//2017-12-27_20-05-28/mysql/columns_priv.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/columns_priv.MYD to /backup//2017-12-27_20-05-28/mysql/columns_priv.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_topic.frm to /backup//2017-12-27_20-05-28/mysql/help_topic.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_topic.MYI to /backup//2017-12-27_20-05-28/mysql/help_topic.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_topic.MYD to /backup//2017-12-27_20-05-28/mysql/help_topic.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_category.frm to /backup//2017-12-27_20-05-28/mysql/help_category.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_category.MYI to /backup//2017-12-27_20-05-28/mysql/help_category.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_category.MYD to /backup//2017-12-27_20-05-28/mysql/help_category.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_relation.frm to /backup//2017-12-27_20-05-28/mysql/help_relation.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_relation.MYI to /backup//2017-12-27_20-05-28/mysql/help_relation.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_relation.MYD to /backup//2017-12-27_20-05-28/mysql/help_relation.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_keyword.frm to /backup//2017-12-27_20-05-28/mysql/help_keyword.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_keyword.MYI to /backup//2017-12-27_20-05-28/mysql/help_keyword.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/help_keyword.MYD to /backup//2017-12-27_20-05-28/mysql/help_keyword.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_name.frm to /backup//2017-12-27_20-05-28/mysql/time_zone_name.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_name.MYI to /backup//2017-12-27_20-05-28/mysql/time_zone_name.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_name.MYD to /backup//2017-12-27_20-05-28/mysql/time_zone_name.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone.frm to /backup//2017-12-27_20-05-28/mysql/time_zone.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone.MYI to /backup//2017-12-27_20-05-28/mysql/time_zone.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone.MYD to /backup//2017-12-27_20-05-28/mysql/time_zone.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition.frm to /backup//2017-12-27_20-05-28/mysql/time_zone_transition.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition.MYI to /backup//2017-12-27_20-05-28/mysql/time_zone_transition.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition.MYD to /backup//2017-12-27_20-05-28/mysql/time_zone_transition.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition_type.frm to /backup//2017-12-27_20-05-28/mysql/time_zone_transition_type.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition_type.MYI to /backup//2017-12-27_20-05-28/mysql/time_zone_transition_type.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_transition_type.MYD to /backup//2017-12-27_20-05-28/mysql/time_zone_transition_type.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_leap_second.frm to /backup//2017-12-27_20-05-28/mysql/time_zone_leap_second.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_leap_second.MYI to /backup//2017-12-27_20-05-28/mysql/time_zone_leap_second.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/time_zone_leap_second.MYD to /backup//2017-12-27_20-05-28/mysql/time_zone_leap_second.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proc.frm to /backup//2017-12-27_20-05-28/mysql/proc.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proc.MYI to /backup//2017-12-27_20-05-28/mysql/proc.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proc.MYD to /backup//2017-12-27_20-05-28/mysql/proc.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/procs_priv.frm to /backup//2017-12-27_20-05-28/mysql/procs_priv.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/procs_priv.MYI to /backup//2017-12-27_20-05-28/mysql/procs_priv.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/procs_priv.MYD to /backup//2017-12-27_20-05-28/mysql/procs_priv.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/general_log.frm to /backup//2017-12-27_20-05-28/mysql/general_log.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/general_log.CSM to /backup//2017-12-27_20-05-28/mysql/general_log.CSM
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/general_log.CSV to /backup//2017-12-27_20-05-28/mysql/general_log.CSV
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/slow_log.frm to /backup//2017-12-27_20-05-28/mysql/slow_log.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/slow_log.CSM to /backup//2017-12-27_20-05-28/mysql/slow_log.CSM
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/slow_log.CSV to /backup//2017-12-27_20-05-28/mysql/slow_log.CSV
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/event.frm to /backup//2017-12-27_20-05-28/mysql/event.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/event.MYI to /backup//2017-12-27_20-05-28/mysql/event.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/event.MYD to /backup//2017-12-27_20-05-28/mysql/event.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/ndb_binlog_index.frm to /backup//2017-12-27_20-05-28/mysql/ndb_binlog_index.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/ndb_binlog_index.MYI to /backup//2017-12-27_20-05-28/mysql/ndb_binlog_index.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/ndb_binlog_index.MYD to /backup//2017-12-27_20-05-28/mysql/ndb_binlog_index.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proxies_priv.frm to /backup//2017-12-27_20-05-28/mysql/proxies_priv.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proxies_priv.MYI to /backup//2017-12-27_20-05-28/mysql/proxies_priv.MYI
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./mysql/proxies_priv.MYD to /backup//2017-12-27_20-05-28/mysql/proxies_priv.MYD
171227 20:05:30 [01] ...done
171227 20:05:30 [00] Writing test/db.opt
171227 20:05:30 [00] ...done
171227 20:05:30 [01] Copying ./performance_schema/db.opt to /backup//2017-12-27_20-05-28/performance_schema/db.opt
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/cond_instances.frm to /backup//2017-12-27_20-05-28/performance_schema/cond_instances.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_current.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_current.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_history.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_history.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_history_long.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_history_long.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_summary_by_instance.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_summary_by_thread_by_event_name.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /backup//2017-12-27_20-05-28/performance_schema/events_waits_summary_global_by_event_name.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/file_instances.frm to /backup//2017-12-27_20-05-28/performance_schema/file_instances.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /backup//2017-12-27_20-05-28/performance_schema/file_summary_by_event_name.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/file_summary_by_instance.frm to /backup//2017-12-27_20-05-28/performance_schema/file_summary_by_instance.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/mutex_instances.frm to /backup//2017-12-27_20-05-28/performance_schema/mutex_instances.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/performance_timers.frm to /backup//2017-12-27_20-05-28/performance_schema/performance_timers.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/rwlock_instances.frm to /backup//2017-12-27_20-05-28/performance_schema/rwlock_instances.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/setup_consumers.frm to /backup//2017-12-27_20-05-28/performance_schema/setup_consumers.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/setup_instruments.frm to /backup//2017-12-27_20-05-28/performance_schema/setup_instruments.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/setup_timers.frm to /backup//2017-12-27_20-05-28/performance_schema/setup_timers.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./performance_schema/threads.frm to /backup//2017-12-27_20-05-28/performance_schema/threads.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./class/db.opt to /backup//2017-12-27_20-05-28/class/db.opt
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./class/tb.frm to /backup//2017-12-27_20-05-28/class/tb.frm
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./test1/db.opt to /backup//2017-12-27_20-05-28/test1/db.opt
171227 20:05:30 [01] ...done
171227 20:05:30 [01] Copying ./test1/course.frm to /backup//2017-12-27_20-05-28/test1/course.frm
171227 20:05:30 [01] ...done
171227 20:05:30 Finished backing up non-InnoDB tables and files
171227 20:05:30 [00] Writing xtrabackup_binlog_info
171227 20:05:30 [00] ...done
171227 20:05:30 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '1603665'
xtrabackup: Stopping log copying thread.
.171227 20:05:30 >> log scanned up to (1603665)
171227 20:05:30 Executing UNLOCK TABLES
171227 20:05:30 All tables unlocked
171227 20:05:30 Backup created in directory '/backup//2017-12-27_20-05-28'
MySQL binlog position: filename 'mysql-bin.000005', position '1006'
171227 20:05:30 [00] Writing backup-my.cnf
171227 20:05:30 [00] ...done
171227 20:05:30 [00] Writing xtrabackup_info
171227 20:05:30 [00] ...done
xtrabackup: Transaction log of lsn (1603665) to (1603665) was copied.
171227 20:05:30 completed OK!
[rootmysql-master ~]# ls /backup/
2017-12-27_19-56-21 2017-12-27_20-05-28
执行操作(首先进行完全备份):innobackupex --apply-log --redo-only 2017-12-27_19-56-21
接着执行增量:innobackupex --apply-log --redo-only 2017-12-27_19-56-21 --incrementaldir=2017-12-27_20-05-28
【 注:需指明完全备份和增量备份目录,2017-12-27_19-56-21是完全备份目录,2017-12-27_20-05-28是增量备份目录】
(1)不小心删除数据库
[rootmysql-master ~]# cd /var/lib/mysql
[rootmysql-master mysql]# ls
aria_log.00000001 ib_logfile0 mysql-bin.000001 mysql-bin.000005 mysql.sock test1
aria_log_control ib_logfile1 mysql-bin.000002 mysql-bin.index performance_schema
class master.info mysql-bin.000003 mysql-relay-log.000005 relay-log.info
ibdata1 mysql mysql-bin.000004 mysql-relay-log.index test
[rootmysql-master mysql]# rm -rf test1
[rootmysql-master mysql]# mysql -uroot
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| class |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.10 sec)
[rootmysql-master]# innobackupex --copy-back /backup/2017-12-27_19-56-21/此处目录指定为全量备份时的目录,所以最终恢复后也只是全
量备份的数据,不能恢复完全
171227 20:43:45 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 version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
Original data directory /var/lib/mysql is not empty!
(3)
[rootmysql-master mysql]# cd /var/lib
[rootmysql-master lib]# cp -a mysql mysql.bak
[rootmysql-master lib]# rm -rf mysql
[rootmysql-master lib]# mkdir mysql
[rootmysql-master lib]# cd mysql
[rootmysql-master mysql]# ls
[rootmysql-master mysql]# innobackupex --copy-back /backup/2017-12-27_19-56-21/
171227 20:40:36 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!".
[rootmysql-master mysql]# chown -R mysql.mysql /var/lib/mysql
[rootmysql-master mysql]# systemctl restart mariadb
[rootmysql-master mysql]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, 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 |
| class |
| mysql |
| performance_schema |
| test |
| test1 |
+--------------------+
6 rows in set (0.00 sec)
MariaDB [(none)]> select * from test1.course;
+------+------+
| id | name |
+------+------+
| 1 | math |
+------+------+
1 row in set (0.00 sec)
MariaDB [(none)]> exit;
Bye
1.[rootmysql-master ~]# innobackupex --apply-log --redo-only 2017-12-27_21-11-13
171227 21:20:58 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!".
innobackupex version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
innobackupex: Can't change dir to '/root/2017-12-27_21-11-13' (Errcode: 2 - No such file or directory)
xtrabackup: cannot my_setwd /root/2017-12-27_21-11-13
解决方法:带上路径,就好了,如下
[rootmysql-master ~]# innobackupex --apply-log --redo-only /backup/
171227 21:21:36 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!".
2.[rootmysql-master ~]# innobackupex --apply-log --redo-only /backup/2017-12-27_21-11-13 --incrementaldir=/backup/2017-12-27_21-13-57
3.模拟数据库误删除
[rootmysql-master mysql]# rm -rf test1
[rootmysql-master mysql]# ls /backup/
2017-12-27_21-11-13 2017-12-27_21-13-57
[rootmysql-master mysql]# innobackupex --copy-back /backup/2017-12-27_21-11-13 【注:全量备份目录】
171227 21:33:21 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 version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
Original data directory /var/lib/mysql is not empty!
恢复的时候发现出现如上错误
解决方法:删除/var/lib/mysql下的所有文件
[rootmysql-master mysql]# rm -rf *
[rootmysql-master mysql]# ls
[rootmysql-master mysql]# innobackupex --copy-back /backup/2017-12-27_21-11-13 成功执行,此目录一定要是全量备份的目录,所以执行命
令的时候一定要找准
171227 21:35:41 innobackupex: Starting the copy-back operation
[rootmysql-master mysql]# chown -R mysql.mysql ./*
[rootmysql-master mysql]# systemctl start mariadb
查看数据恢复情况:成功恢复
MariaDB [(none)]> select * from test1.course;
+------+-------+
| id | name |
+------+-------+
| 1 | math |
| 2 | linux |
+------+-------+