测试xtrabackup的增量备份与恢复

XtraBackup提供了增量备份恢复的功能,不过,其增量的设计方案与RMAN这类备份工具可是完全不同的哟,接下来,我们以实例来说明这一点。

下列测试基于最新的xtrabackup1.6版本。关于xtrabackup1.6的编译安装请参考:http://space.itpub.net/7607759/viewspace-697899

建库如下:

mysql> create database jss;

Query OK, 1 row affected (0.01 sec)

mysql> use jss;

Database changed

mysql> create table j1(id int);

Query OK, 0 rows affected (0.06 sec)

mysql> insert into j1 values (1);

    Query OK, 1 row affected (0.01 sec)

创建全备集:

[root@rhel5u3 ~]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306/my.cnf --user=root --password=123456 /data/backup/full/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

110617 12:04:45  innobackupex: Starting mysql with options:  --defaults-file='/data/mysqldata/3306/my.cnf' --password='123456' --user='root' --unbuffered --

110617 12:04:45  innobackupex: Connected to database with mysql child process (pid=16969)

110617 12:04:51  innobackupex: Connection to database server closed

IMPORTANT: Please check that the backup run completes successfully.

           At the end of a successful backup run innobackupex

           prints "completed OK!".

innobackupex: Using mysql  Ver 14.14 Distrib 5.5.12, for Linux (x86_64) using  EditLine wrapper

innobackupex: Using mysql server version Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

innobackupex: Created backup directory /data/backup/full/2011-06-17_12-04-51

110617 12:04:51  innobackupex: Starting mysql with options:  --defaults-file='/data/mysqldata/3306/my.cnf' --password='123456' --user='root' --unbuffered --

110617 12:04:51  innobackupex: Connected to database with mysql child process (pid=16997)

110617 12:04:55  innobackupex: Connection to database server closed

110617 12:04:55  innobackupex: Starting ibbackup with command: xtrabackup_55  --defaults-file="/data/mysqldata/3306/my.cnf" --backup --suspend-at-end --target-dir=/data/backup/full/2011-06-17_12-04-51

innobackupex: Waiting for ibbackup (pid=17009) to suspend

innobackupex: Suspend file '/data/backup/full/2011-06-17_12-04-51/xtrabackup_suspended'

xtrabackup_55  Ver undefined Rev undefined for 5.5.10 Linux (x86_64)

xtrabackup: uses posix_fadvise().

xtrabackup: cd to /data/mysqldata/3306/data

xtrabackup: Target instance is assumed as followings.

xtrabackup:   innodb_data_home_dir = /data/mysqldata/3306/innodb_ts

xtrabackup:   innodb_data_file_path = ibdata1:10M:autoextend

xtrabackup:   innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log

xtrabackup:   innodb_log_files_in_group = 2

xtrabackup:   innodb_log_file_size = 5242880

110617 12:04:55 InnoDB: Using Linux native AIO

110617 12:04:55  InnoDB: Warning: allocated tablespace 7, old maximum was 0

>> log scanned up to (111259421)

[01] Copying /data/mysqldata/3306/innodb_ts/ibdata1 

     to /data/backup/full/2011-06-17_12-04-51/ibdata1

>> log scanned up to (111259421)

[01]        ...done

[01] Copying ./test/j2.ibd 

     to /data/backup/full/2011-06-17_12-04-51/test/j2.ibd

[01]        ...done

[01] Copying ./test/j3.ibd 

     to /data/backup/full/2011-06-17_12-04-51/test/j3.ibd

[01]        ...done

[01] Copying ./jss/j1.ibd 

     to /data/backup/full/2011-06-17_12-04-51/jss/j1.ibd

[01]        ...done

110617 12:05:09  innobackupex: Continuing after ibbackup has suspended

110617 12:05:09  innobackupex: Starting mysql with options:  --defaults-file='/data/mysqldata/3306/my.cnf' --password='123456' --user='root' --unbuffered --

110617 12:05:09  innobackupex: Connected to database with mysql child process (pid=17024)

>> log scanned up to (111259421)

110617 12:05:13  innobackupex: Starting to lock all tables...

>> log scanned up to (111259421)

>> log scanned up to (111259421)

110617 12:05:24  innobackupex: All tables locked and flushed to disk

110617 12:05:24  innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,

innobackupex: .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV and .opt files in

innobackupex: subdirectories of '/data/mysqldata/3306/data'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j2.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j1.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j3.frm'

innobackupex: Backing up files '/data/mysqldata/3306/data/performance_schema/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (18 files)

innobackupex: Backing up file '/data/mysqldata/3306/data/jss/j1.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/jss/db.opt'

innobackupex: Backing up files '/data/mysqldata/3306/data/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (72 files)

110617 12:05:26  innobackupex: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, .ARM, .ARZ, .CSV, .CSM and .opt files

innobackupex: Resuming ibbackup

xtrabackup: The latest check point (for incremental): '111259421'

>> log scanned up to (111259421)

xtrabackup: Stopping log copying thread.

xtrabackup: Transaction log of lsn (111259421) to (111259421) was copied.

110617 12:05:29  innobackupex: All tables unlocked

110617 12:05:29  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/data/backup/full/2011-06-17_12-04-51'

innobackupex: MySQL binlog position: filename 'mysql-bin.000010', position 454

    110617 12:05:29  innobackupex: completed OK!

登录到数据库,创建几个新的对象:

mysql> use jss;

Database changed

mysql> show tables;

+---------------+

| Tables_in_jss |

+---------------+

| j1            |

+---------------+

1 row in set (0.00 sec)

mysql> truncate table j1;

Query OK, 0 rows affected (0.01 sec)

mysql> create table j2(id int);

Query OK, 0 rows affected (0.04 sec)

mysql> insert into j2 values (1);

    Query OK, 1 row affected (0.01 sec)

执行增量备份:

[root@rhel5u3 ~]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306/my.cnf --incremental --incremental-basedir=/data/backup/full/2011-06-17_12-04-51 --user=root --password='123456' /data/backup/rec/

Use of uninitialized value in scalar chomp at /usr/local/mysql55/bin/innobackupex line 1657.

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

110617 12:09:06  innobackupex: Starting mysql with options:  --defaults-file='/data/mysqldata/3306/my.cnf' --password='123456' --user='root' --unbuffered --

110617 12:09:06  innobackupex: Connected to database with mysql child process (pid=17195)

110617 12:09:13  innobackupex: Connection to database server closed

IMPORTANT: Please check that the backup run completes successfully.

           At the end of a successful backup run innobackupex

           prints "completed OK!".

innobackupex: Using mysql  Ver 14.14 Distrib 5.5.12, for Linux (x86_64) using  EditLine wrapper

innobackupex: Using mysql server version Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

innobackupex: Created backup directory /data/backup/rec/2011-06-17_12-09-13

110617 12:09:13  innobackupex: Starting mysql with options:  --defaults-file='/data/mysqldata/3306/my.cnf' --password='123456' --user='root' --unbuffered --

110617 12:09:13  innobackupex: Connected to database with mysql child process (pid=17223)

110617 12:09:17  innobackupex: Connection to database server closed

110617 12:09:17  innobackupex: Starting ibbackup with command: xtrabackup_55  --defaults-file="/data/mysqldata/3306/my.cnf" --backup --suspend-at-end --target-dir=/data/backup/rec/2011-06-17_12-09-13 --incremental-basedir='/data/backup/full/2011-06-17_12-04-51'

innobackupex: Waiting for ibbackup (pid=17235) to suspend

innobackupex: Suspend file '/data/backup/rec/2011-06-17_12-09-13/xtrabackup_suspended'

xtrabackup_55  Ver undefined Rev undefined for 5.5.10 Linux (x86_64)

incremental backup from 111259421 is enabled.

xtrabackup: uses posix_fadvise().

xtrabackup: cd to /data/mysqldata/3306/data

xtrabackup: Target instance is assumed as followings.

xtrabackup:   innodb_data_home_dir = /data/mysqldata/3306/innodb_ts

xtrabackup:   innodb_data_file_path = ibdata1:10M:autoextend

xtrabackup:   innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log

xtrabackup:   innodb_log_files_in_group = 2

xtrabackup:   innodb_log_file_size = 5242880

110617 12:09:17 InnoDB: Using Linux native AIO

110617 12:09:17  InnoDB: Warning: allocated tablespace 7, old maximum was 0

>> log scanned up to (111262528)

[01] Copying /data/mysqldata/3306/innodb_ts/ibdata1 

     to /data/backup/rec/2011-06-17_12-09-13/ibdata1.delta

[01]        ...done

[01] Copying ./test/j2.ibd 

     to /data/backup/rec/2011-06-17_12-09-13/test/j2.ibd.delta

[01]        ...done

[01] Copying ./test/j3.ibd 

     to /data/backup/rec/2011-06-17_12-09-13/test/j3.ibd.delta

[01]        ...done

[01] Copying ./jss/j2.ibd 

     to /data/backup/rec/2011-06-17_12-09-13/jss/j2.ibd.delta

[01]        ...done

[01] Copying ./jss/j1.ibd 

     to /data/backup/rec/2011-06-17_12-09-13/jss/j1.ibd.delta

[01]        ...done

110617 12:09:21  innobackupex: Continuing after ibbackup has suspended

110617 12:09:21  innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,

innobackupex: .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV and .opt files in

innobackupex: subdirectories of '/data/mysqldata/3306/data'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j2.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j1.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/test/j3.frm'

innobackupex: Backing up files '/data/mysqldata/3306/data/performance_schema/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (18 files)

innobackupex: Backing up file '/data/mysqldata/3306/data/jss/j2.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/jss/j1.frm'

innobackupex: Backing up file '/data/mysqldata/3306/data/jss/db.opt'

innobackupex: Backing up files '/data/mysqldata/3306/data/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (72 files)

>> log scanned up to (111262528)

110617 12:09:24  innobackupex: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, .ARM, .ARZ, .CSV, .CSM and .opt files

innobackupex: Resuming ibbackup

xtrabackup: The latest check point (for incremental): '111262528'

>> log scanned up to (111262528)

xtrabackup: Stopping log copying thread.

xtrabackup: Transaction log of lsn (111262528) to (111262528) was copied.

innobackupex: Backup created in directory '/data/backup/rec/2011-06-17_12-09-13'

    110617 12:09:24  innobackupex: completed OK!

增量备份仅针对InnoDB这类支持事务的引擎,对于MyISAM等引擎,则仍然是全备了。

停止MySQL服务:

[root@rhel5u3 ~]# mysqladmin -uroot -p'123456' -S /data/mysqldata/3306/mysql.sock shutdown

110617 14:36:02 mysqld_safe mysqld from pid file /data/mysqldata/3306/data/rhel5u3.pid ended

    [1]+  Done                    mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf  (wd: /data/mysqldata/3306)

移动之前的数据目录:

    [root@rhel5u3 ~]# mv /data/mysqldata/3306 /data/mysqldata/3306-jss-bak

创建工作目录:

[root@rhel5u3 ~]# mkdir /data/mysqldata/3306

[root@rhel5u3 ~]# cd /data/mysqldata/3306

    [root@rhel5u3 3306]# mkdir tmp binlog data innodb_log innodb_ts

Prepare完整备份集:

[root@rhel5u3 3306]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306-jss-bak/my.cnf --apply-log --redo-only /data/backup/full/2011-06-17_12-04-51 --user=root --password='123456'

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the apply-log run completes successfully.

           At the end of a successful apply-log run innobackupex

           prints "completed OK!".

110617 14:40:29  innobackupex: Starting ibbackup with command: xtrabackup_55  --defaults-file="/data/mysqldata/3306-jss-bak/my.cnf" --prepare --target-dir=/data/backup/full/2011-06-17_12-04-51 --apply-log-only

xtrabackup_55  Ver undefined Rev undefined for 5.5.10 Linux (x86_64)

xtrabackup: cd to /data/backup/full/2011-06-17_12-04-51

xtrabackup: This target seems to be not prepared yet.

xtrabackup: xtrabackup_logfile detected: size=2359296, start_lsn=(111259421)

xtrabackup: Temporary instance for recovery is set as followings.

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 = 2359296

110617 14:40:29 InnoDB: Using Linux native AIO

xtrabackup: Starting InnoDB instance for recovery.

xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)

110617 14:40:29 InnoDB: The InnoDB memory heap is disabled

110617 14:40:29 InnoDB: Mutexes and rw_locks use GCC atomic builtins

110617 14:40:29 InnoDB: Compressed tables use zlib 1.2.3

110617 14:40:29 InnoDB: Using Linux native AIO

110617 14:40:29 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead

110617 14:40:29 InnoDB: Initializing buffer pool, size = 100.0M

110617 14:40:29 InnoDB: Completed initialization of buffer pool

110617 14:40:29 InnoDB: highest supported file format is Barracuda.

InnoDB: The log sequence number in ibdata files does not match

InnoDB: the log sequence number in the ib_logfiles!

110617 14:40:29  InnoDB: Database was not shut down normally!

InnoDB: Starting crash recovery.

InnoDB: Reading tablespace information from the .ibd files...

InnoDB: Last MySQL binlog file position 0 454, file name ./mysql-bin.000010

[notice (again)]

  If you use binary log and don't use any hack of group commit,

  the binary log position seems to be:

InnoDB: Last MySQL binlog file position 0 454, file name ./mysql-bin.000010

xtrabackup: starting shutdown with innodb_fast_shutdown = 1

110617 14:40:29  InnoDB: Starting shutdown...

110617 14:40:30  InnoDB: Shutdown completed; log sequence number 111259421

    110617 14:40:30  innobackupex: completed OK!

Prepare增量备份集:

[root@rhel5u3 3306]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306-jss-bak/my.cnf --apply-log --redo-only /data/backup/full/2011-06-17_12-04-51 --incremental-dir=/data/backup/rec/2011-06-17_12-09-13 --user=root --password='123456'

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the apply-log run completes successfully.

           At the end of a successful apply-log run innobackupex

           prints "completed OK!".

110617 14:42:19  innobackupex: Starting ibbackup with command: xtrabackup_55  --defaults-file="/data/mysqldata/3306-jss-bak/my.cnf" --prepare --target-dir=/data/backup/full/2011-06-17_12-04-51 --apply-log-only --incremental-dir=/data/backup/rec/2011-06-17_12-09-13

xtrabackup_55  Ver undefined Rev undefined for 5.5.10 Linux (x86_64)

incremental backup from 111259421 is enabled.

xtrabackup: cd to /data/backup/full/2011-06-17_12-04-51

xtrabackup: This target seems to be already prepared.

xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(111262528)

xtrabackup: page size for /data/backup/rec/2011-06-17_12-09-13/ibdata1.delta is 16384 bytes

Applying /data/backup/rec/2011-06-17_12-09-13/ibdata1.delta ...

xtrabackup: page size for /data/backup/rec/2011-06-17_12-09-13/test/j3.ibd.delta is 16384 bytes

Applying /data/backup/rec/2011-06-17_12-09-13/test/j3.ibd.delta ...

xtrabackup: page size for /data/backup/rec/2011-06-17_12-09-13/test/j2.ibd.delta is 16384 bytes

Applying /data/backup/rec/2011-06-17_12-09-13/test/j2.ibd.delta ...

xtrabackup: page size for /data/backup/rec/2011-06-17_12-09-13/jss/j1.ibd.delta is 16384 bytes

Applying /data/backup/rec/2011-06-17_12-09-13/jss/j1.ibd.delta ...

xtrabackup: page size for /data/backup/rec/2011-06-17_12-09-13/jss/j2.ibd.delta is 16384 bytes

110617 14:42:19  InnoDB: Operating system error number 2 in a file operation.

InnoDB: The error means the system cannot find the path specified.

xtrabackup: error: cannot open /data/backup/full/2011-06-17_12-04-51/jss/j2.ibd

xtrabackup: Error: xtrabackup_apply_delta() failed.

xtrabackup: Temporary instance for recovery is set as followings.

xtrabackup:   innodb_data_home_dir = ./

xtrabackup:   innodb_data_file_path = ibdata1:10M:autoextend

xtrabackup:   innodb_log_group_home_dir = /data/backup/rec/2011-06-17_12-09-13

xtrabackup:   innodb_log_files_in_group = 1

xtrabackup:   innodb_log_file_size = 2097152

110617 14:42:19 InnoDB: Using Linux native AIO

xtrabackup: Starting InnoDB instance for recovery.

xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)

110617 14:42:19 InnoDB: The InnoDB memory heap is disabled

110617 14:42:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins

110617 14:42:19 InnoDB: Compressed tables use zlib 1.2.3

110617 14:42:19 InnoDB: Using Linux native AIO

110617 14:42:19 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead

110617 14:42:19 InnoDB: Initializing buffer pool, size = 100.0M

110617 14:42:19 InnoDB: Completed initialization of buffer pool

110617 14:42:19 InnoDB: highest supported file format is Barracuda.

InnoDB: The log sequence number in ibdata files does not match

InnoDB: the log sequence number in the ib_logfiles!

110617 14:42:19  InnoDB: Database was not shut down normally!

InnoDB: Starting crash recovery.

InnoDB: Reading tablespace information from the .ibd files...

InnoDB: Last MySQL binlog file position 0 720, file name ./mysql-bin.000010

[notice (again)]

  If you use binary log and don't use any hack of group commit,

  the binary log position seems to be:

InnoDB: Last MySQL binlog file position 0 720, file name ./mysql-bin.000010

xtrabackup: starting shutdown with innodb_fast_shutdown = 1

110617 14:42:19  InnoDB: Starting shutdown...

110617 14:42:20  InnoDB: Shutdown completed; log sequence number 111262528

    110617 14:42:20  innobackupex: completed OK!

杯具啊,j2对象是在全备之后创建的,全备份集中并不存在,因此应用增量时就报了错,(见上面加粗部分),此时如果原始数据文件已经损坏,那么j2的数据就无法恢复了,因为缺少了其数据文件。

再次prepare全备集,回滚那些未提交的事务,这一步中innobackupex也会自动创建innodb日志文件:

[root@rhel5u3 3306]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306-jss-bak/my.cnf --apply-log /data/backup/full/2011-06-17_12-04-51 --user=root --password='123456'

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

...................

...................

xtrabackup: starting shutdown with innodb_fast_shutdown = 1

110617 14:43:12  InnoDB: Starting shutdown...

110617 14:43:13  InnoDB: Shutdown completed; log sequence number 111263852

    110617 14:43:13  innobackupex: completed OK!

执行恢复操作:

[root@rhel5u3 3306]# /usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306-jss-bak/my.cnf --copy-back /data/backup/full/2011-06-17_12-04-51

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy

and Percona Inc 2009-2011.  All Rights Reserved.

This software is published under

the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the copy-back run completes successfully.

           At the end of a successful copy-back run innobackupex

           prints "completed OK!".

innobackupex: Starting to copy MyISAM tables, indexes,

innobackupex: .MRG, .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV, .opt, and .frm files

innobackupex: in '/data/backup/full/2011-06-17_12-04-51'

innobackupex: back to original data directory '/data/mysqldata/3306/data'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/xtrabackup_binary'

innobackupex: Copying directory '/data/backup/full/2011-06-17_12-04-51/test'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/xtrabackup_checkpoints'

innobackupex: Copying directory '/data/backup/full/2011-06-17_12-04-51/performance_schema'

innobackupex: Copying directory '/data/backup/full/2011-06-17_12-04-51/jss'

innobackupex: Copying directory '/data/backup/full/2011-06-17_12-04-51/mysql'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/xtrabackup_binlog_info'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/xtrabackup_binlog_pos_innodb'

innobackupex: Starting to copy InnoDB tables and indexes

innobackupex: in '/data/backup/full/2011-06-17_12-04-51'

innobackupex: back to original InnoDB data directory '/data/mysqldata/3306/innodb_ts'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/ibdata1'

innobackupex: Starting to copy InnoDB log files

innobackupex: in '/data/backup/full/2011-06-17_12-04-51'

innobackupex: back to original InnoDB log directory '/data/mysqldata/3306/innodb_log'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/ib_logfile0'

innobackupex: Copying file '/data/backup/full/2011-06-17_12-04-51/ib_logfile1'

innobackupex: Finished copying back files.

    110617 15:03:02  innobackupex: completed OK!

复制初始化参数文件,修改权限及属主:

[root@rhel5u3 3306]# cd ..

[root@rhel5u3 mysqldata]# cp /data/mysqldata/3306-jss-bak/my.cnf /data/mysqldata/3306/

    [root@rhel5u3 mysqldata]# chown mysql:mysql 3306 -R

Ok,恢复完成,接下来启动MySQL服务:

    [root@rhel5u3 mysqldata]# mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

登录进去查看:

mysql> use jss;

Database changed

mysql> show tables;

+---------------+

| Tables_in_jss |

+---------------+

| j1            |

+---------------+

    1 row in set (0.01 sec)

Shit,第二次创建的j2果然不存在,甚至连结构都没有,怎么回事儿呢,经过分析,原来是在prepare时,XtraBackup并没有将增量备份集中,属于新建对象的.frm文件复制到完整备份集目录,因此在执行copy-back时,这部分文件自然也就没有复制回数据文件路径。

不过,考虑到前面prepare增量集时出现的错误,即使结构文件存在,由于数据文件不存在,这个对象也仍然是打不开了。

此时查询information_schema中的相关对象,倒是能够找到jss.j2对象的定义,这是由于innodb对象元数据保存在系统表空间"innodb_data_home_dir"指定的文件中,这也是增量备份集中新增对象唯一留下的痕迹了。

悲催的innobackupex,这种增量设定怎么看都像是在故意难为DBA啊~~~

原文地址:https://www.cnblogs.com/ylqmf/p/2745403.html