percona mysql备份与恢复(二) --------增量备份与恢复

来源:互联网 发布:淘宝网下载苹果版 编辑:程序博客网 时间:2024/04/29 07:43

author:skate
time:2012/06/27

percona mysql增量备份与恢复

 

版本:
mysql> select version();
+------------+
| version()  |
+------------+
| 5.5.24-log |
+------------+
1 row in set (0.05 sec)

 

步骤:

1.全备
2.增量备份
3.prepare增量备份
4.restore增量备份


1.做个full备份是必须的
[root@localhost data]# innobackupex --user=root   /data/backup/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

120627 17:49:43  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:49:43  innobackupex: Connected to database with mysql child process (pid=16053)
120627 17:49:49  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.12 Distrib 5.0.95, for redhat-linux-gnu (i686) using readline 5.1
innobackupex: Using mysql server version Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

innobackupex: Created backup directory /data/backup/2012-06-27_17-49-49
120627 17:49:49  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:49:49  innobackupex: Connected to database with mysql child process (pid=16077)
120627 17:49:51  innobackupex: Connection to database server closed

120627 17:49:51  innobackupex: Starting ibbackup with command: xtrabackup_55 --backup --suspend-at-end --target-dir=/data/backup/2012-06-27_17-49-49
innobackupex: Waiting for ibbackup (pid=16084) to suspend
innobackupex: Suspend file '/data/backup/2012-06-27_17-49-49/xtrabackup_suspended'

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/usr/local/mysql/data/
xtrabackup: Target instance is assumed 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 = 2
xtrabackup:   innodb_log_file_size = 5242880
120627 17:49:51 InnoDB: Using Linux native AIO
>> log scanned up to (1598476)
[01] Copying ./ibdata1 to /data/backup/2012-06-27_17-49-49/ibdata1
[01]        ...done

120627 17:49:53  innobackupex: Continuing after ibbackup has suspended
120627 17:49:53  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:49:53  innobackupex: Connected to database with mysql child process (pid=16098)
120627 17:49:55  innobackupex: Starting to lock all tables...
>> log scanned up to (1598476)
>> log scanned up to (1598476)
120627 17:50:06  innobackupex: All tables locked and flushed to disk

120627 17:50:06  innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex: .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV and .opt files in
innobackupex: subdirectories of '/data/mysql/usr/local/mysql/data/'
innobackupex: Backing up files '/data/mysql/usr/local/mysql/data//performance_schema/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (18 files)
innobackupex: Backing up files '/data/mysql/usr/local/mysql/data//mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (72 files)
>> log scanned up to (1598476)
120627 17:50:08  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): '1598476'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1598476)

xtrabackup: Transaction log of lsn (1598476) to (1598476) was copied.
120627 17:50:10  innobackupex: All tables unlocked
120627 17:50:10  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/data/backup/2012-06-27_17-49-49'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position 4580
120627 17:50:10  innobackupex: completed OK!
[root@localhost data]#

 

看看备份的类型


[root@localhost backup]# more /data/backup/2012-06-27_17-49-49/xtrabackup_checkpoints
backup_type = full-backuped
from_lsn = 0
to_lsn = 1598476
last_lsn = 1598476
[root@localhost backup]#

 

2.
增量备份1

[root@localhost data]# innobackupex --user=root --incremental /data/backup --incremental-basedir=/data/backup/2012-06-27_17-49-49/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

120627 17:53:40  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:53:40  innobackupex: Connected to database with mysql child process (pid=16230)
120627 17:53:46  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.12 Distrib 5.0.95, for redhat-linux-gnu (i686) using readline 5.1
innobackupex: Using mysql server version Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

innobackupex: Created backup directory /data/backup/2012-06-27_17-53-46
120627 17:53:46  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:53:46  innobackupex: Connected to database with mysql child process (pid=16256)
120627 17:53:48  innobackupex: Connection to database server closed

120627 17:53:48  innobackupex: Starting ibbackup with command: xtrabackup_55 --backup --suspend-at-end --target-dir=/data/backup/2012-06-27_17-53-46 --incremental-basedir='/data/backup/2012-06-27_17-49-49/'
innobackupex: Waiting for ibbackup (pid=16264) to suspend
innobackupex: Suspend file '/data/backup/2012-06-27_17-53-46/xtrabackup_suspended'

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
incremental backup from 1598476 is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/usr/local/mysql/data/
xtrabackup: Target instance is assumed 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 = 2
xtrabackup:   innodb_log_file_size = 5242880
120627 17:53:48 InnoDB: Using Linux native AIO
>> log scanned up to (1598476)
[01] Copying ./ibdata1 to /data/backup/2012-06-27_17-53-46/ibdata1.delta
[01]        ...done

120627 17:53:52  innobackupex: Continuing after ibbackup has suspended
120627 17:53:52  innobackupex: Starting mysql with options:  --user='root' --unbuffered --
120627 17:53:52  innobackupex: Connected to database with mysql child process (pid=16278)
>> log scanned up to (1598476)
120627 17:53:54  innobackupex: Starting to lock all tables...
>> log scanned up to (1598476)
>> log scanned up to (1598476)
120627 17:54:05  innobackupex: All tables locked and flushed to disk

120627 17:54:05  innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex: .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV and .opt files in
innobackupex: subdirectories of '/data/mysql/usr/local/mysql/data/'
innobackupex: Backing up files '/data/mysql/usr/local/mysql/data//performance_schema/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (18 files)
innobackupex: Backing up files '/data/mysql/usr/local/mysql/data//mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (72 files)
120627 17:54:06  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): '1598476'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1598476)

xtrabackup: Transaction log of lsn (1598476) to (1598476) was copied.
120627 17:54:08  innobackupex: All tables unlocked
120627 17:54:08  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/data/backup/2012-06-27_17-53-46'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position 5222
120627 17:54:08  innobackupex: completed OK!
[root@localhost data]#

 

查看此备份类型


[root@localhost backup]# more /data/backup/2012-06-27_17-53-46/xtrabackup_checkpoints
backup_type = incremental
from_lsn = 1598476
to_lsn = 1598476
last_lsn = 1598476
[root@localhost backup]#


增量备份2

[root@localhost data]# innobackupex --user=root --incremental /data/backup --incremental-basedir=/data/backup/2012-06-27_17-53-46/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  All Rights Reserved.

.....
.....

xtrabackup: Transaction log of lsn (1598476) to (1598476) was copied.
120627 18:13:55  innobackupex: All tables unlocked
120627 18:13:55  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/data/backup/2012-06-27_18-13-35'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position 5411
120627 18:13:55  innobackupex: completed OK!

 

查看此备份类型
[root@localhost backup]# more /data/backup/2012-06-27_18-13-35/xtrabackup_checkpoints
backup_type = incremental
from_lsn = 1598476
to_lsn = 1598476
last_lsn = 1598476

增量备份3
[root@localhost data]# innobackupex --user=root --incremental /data/backup --incremental-basedir=/data/backup/2012-06-27_18-13-35/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  All Rights Reserved.

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

xtrabackup: Transaction log of lsn (1598476) to (1598476) was copied.
120627 18:30:37  innobackupex: All tables unlocked
120627 18:30:37  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/data/backup/2012-06-27_18-30-15'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position 5600
120627 18:30:37  innobackupex: completed OK!
[root@localhost data]#

 

查看此备份类型

[root@localhost backup]# more /data/backup/2012-06-27_18-30-15/xtrabackup_checkpoints
backup_type = incremental
from_lsn = 1598476
to_lsn = 1598476
last_lsn = 1598476
[root@localhost backup]#


full备份应用log,提交committed事务

[root@localhost backup]# innobackupex --apply-log --redo-only /data/backup/2012-06-27_17-49-49/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  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!".

120627 18:38:09  innobackupex: Starting ibbackup with command: xtrabackup_55 --prepare --target-dir=/data/backup/2012-06-27_17-49-49 --apply-log-only

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
xtrabackup: cd to /data/backup/2012-06-27_17-49-49
xtrabackup: This target seems to be not prepared yet.
xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1598476)
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 = 2097152
120627 18:38:09 InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
120627 18:38:09 InnoDB: The InnoDB memory heap is disabled
120627 18:38:09 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120627 18:38:09 InnoDB: Compressed tables use zlib 1.2.3
120627 18:38:09 InnoDB: Using Linux native AIO
120627 18:38:09 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
120627 18:38:09 InnoDB: Initializing buffer pool, size = 100.0M
120627 18:38:09 InnoDB: Completed initialization of buffer pool
120627 18:38:09 InnoDB: highest supported file format is Barracuda.

[notice (again)]
  If you use binary log and don't use any hack of group commit,
  the binary log position seems to be:

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
120627 18:38:10  InnoDB: Starting shutdown...
120627 18:38:10  InnoDB: Shutdown completed; log sequence number 1598476
120627 18:38:10  innobackupex: completed OK!
[root@localhost backup]#

增量备份1应用log,提交committed事务

[root@localhost backup]# innobackupex --apply-log --redo-only /data/backup/2012-06-27_17-49-49/ --incremental-dir=/data/backup/2012-06-27_17-53-46/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  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!".

 

120627 18:39:42  innobackupex: Starting ibbackup with command: xtrabackup_55 --prepare --target-dir=/data/backup/2012-06-27_17-49-49 --apply-log-only --incremental-dir=/data/backup/2012-06-27_17-53-46/

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
incremental backup from 1598476 is enabled.
xtrabackup: cd to /data/backup/2012-06-27_17-49-49
xtrabackup: This target seems to be already prepared.
xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1598476)
xtrabackup: page size for /data/backup/2012-06-27_17-53-46//ibdata1.delta is 16384 bytes
Applying /data/backup/2012-06-27_17-53-46//ibdata1.delta ...
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/2012-06-27_17-53-46/
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 2097152
120627 18:39:42 InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
120627 18:39:42 InnoDB: The InnoDB memory heap is disabled
120627 18:39:42 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120627 18:39:42 InnoDB: Compressed tables use zlib 1.2.3
120627 18:39:42 InnoDB: Using Linux native AIO
120627 18:39:42 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
120627 18:39:42 InnoDB: Initializing buffer pool, size = 100.0M
120627 18:39:42 InnoDB: Completed initialization of buffer pool
120627 18:39:42 InnoDB: highest supported file format is Barracuda.

[notice (again)]
  If you use binary log and don't use any hack of group commit,
  the binary log position seems to be:

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
120627 18:39:42  InnoDB: Starting shutdown...
120627 18:39:43  InnoDB: Shutdown completed; log sequence number 1598476
innobackupex: Starting to copy non-InnoDB files in '/data/backup/2012-06-27_17-53-46/'
innobackupex: to the full backup directory '/data/backup/2012-06-27_17-49-49'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/xtrabackup_binlog_info'
innobackupex: Creating directory '/data/backup/2012-06-27_17-49-49performance_schema'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/performance_timers.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/setup_timers.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/rwlock_instances.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/cond_instances.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_summary_by_instance.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/mutex_instances.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/file_summary_by_event_name.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_history.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_current.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/db.opt'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_summary_by_thread_by_event_name.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/file_summary_by_instance.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/setup_instruments.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/file_instances.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/setup_consumers.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/threads.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_history_long.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/events_waits_summary_global_by_event_name.frm'
innobackupex: Creating directory '/data/backup/2012-06-27_17-49-49mysql'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_topic.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/host.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/servers.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/tables_priv.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proc.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/plugin.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/func.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/host.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/user.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/db.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_leap_second.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proxies_priv.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/slow_log.CSV'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_name.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/event.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition_type.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/columns_priv.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_category.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/general_log.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition_type.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_name.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_keyword.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_topic.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/procs_priv.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_relation.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/procs_priv.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_keyword.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_keyword.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/user.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_category.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/event.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/func.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/slow_log.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/db.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/db.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/host.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_leap_second.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_relation.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/procs_priv.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/func.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_name.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_topic.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proc.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/servers.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proc.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/general_log.CSM'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_leap_second.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/columns_priv.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/ndb_binlog_index.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/tables_priv.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/user.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proxies_priv.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/plugin.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/ndb_binlog_index.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_category.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/servers.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/tables_priv.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition_type.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/columns_priv.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/help_relation.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/ndb_binlog_index.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/proxies_priv.frm'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/general_log.CSV'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/plugin.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/event.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/slow_log.CSM'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition.MYI'
innobackupex: Creating directory '/data/backup/2012-06-27_17-49-49test'
120627 18:39:44  innobackupex: completed OK!
[root@localhost backup]#

增量备份2应用log,提交committed事务

[root@localhost backup]# innobackupex --apply-log --redo-only /data/backup/2012-06-27_17-49-49/ --incremental-dir=/data/backup/2012-06-27_18-13-35/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
.....
.....
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/plugin.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/event.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/slow_log.CSM'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition.MYI'
120627 18:42:47  innobackupex: completed OK!
[root@localhost backup]#

 

增量备份3应用log,提交committed事务

[root@localhost backup]# innobackupex --apply-log --redo-only /data/backup/2012-06-27_17-49-49/ --incremental-dir=/data/backup/2012-06-27_18-30-15/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  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!".

.....
.....
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/plugin.MYI'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/event.MYD'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/slow_log.CSM'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/time_zone_transition.MYI'
120627 18:43:38  innobackupex: completed OK!
[root@localhost backup]#

 

把所有的增量备份合并到full全备份里,然后回滚uncommitted的事务

[root@localhost backup]# innobackupex --apply-log  /data/backup/2012-06-27_17-49-49/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  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!".

120627 18:45:32  innobackupex: Starting ibbackup with command: xtrabackup_55 --prepare --target-dir=/data/backup/2012-06-27_17-49-49

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
xtrabackup: cd to /data/backup/2012-06-27_17-49-49
xtrabackup: This target seems to be already prepared.
xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
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 = 2
xtrabackup:   innodb_log_file_size = 5242880
120627 18:45:32 InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
120627 18:45:32 InnoDB: The InnoDB memory heap is disabled
120627 18:45:32 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120627 18:45:32 InnoDB: Compressed tables use zlib 1.2.3
120627 18:45:32 InnoDB: Using Linux native AIO
120627 18:45:32 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
120627 18:45:32 InnoDB: Initializing buffer pool, size = 100.0M
120627 18:45:32 InnoDB: Completed initialization of buffer pool
120627 18:45:32  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
120627 18:45:32  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
120627 18:45:33 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!
120627 18:45:33  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
120627 18:45:33  InnoDB: Waiting for the background threads to start
120627 18:45:34 Percona XtraDB (http://www.percona.com) 1.1.8-20.1 started; log sequence number 1598988

[notice (again)]
  If you use binary log and don't use any hack of group commit,
  the binary log position seems to be:

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
120627 18:45:34  InnoDB: Starting shutdown...
120627 18:45:38  InnoDB: Shutdown completed; log sequence number 1598988

120627 18:45:38  innobackupex: Restarting xtrabackup with command: xtrabackup_55 --prepare --target-dir=/data/backup/2012-06-27_17-49-49
for creating ib_logfile*

xtrabackup_55 version 2.0.0 for Percona Server 5.5.16 Linux (i686) (revision id: 417)
xtrabackup: cd to /data/backup/2012-06-27_17-49-49
xtrabackup: This target seems to be already prepared.
xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
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 = 2
xtrabackup:   innodb_log_file_size = 5242880
120627 18:45:38 InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
120627 18:45:38 InnoDB: The InnoDB memory heap is disabled
120627 18:45:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120627 18:45:38 InnoDB: Compressed tables use zlib 1.2.3
120627 18:45:38 InnoDB: Using Linux native AIO
120627 18:45:38 InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
120627 18:45:38 InnoDB: Initializing buffer pool, size = 100.0M
120627 18:45:38 InnoDB: Completed initialization of buffer pool
120627 18:45:38 InnoDB: highest supported file format is Barracuda.
120627 18:45:38  InnoDB: Waiting for the background threads to start
120627 18:45:39 Percona XtraDB (http://www.percona.com) 1.1.8-20.1 started; log sequence number 1598988

[notice (again)]
  If you use binary log and don't use any hack of group commit,
  the binary log position seems to be:

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
120627 18:45:39  InnoDB: Starting shutdown...
120627 18:45:43  InnoDB: Shutdown completed; log sequence number 1598988
120627 18:45:43  innobackupex: completed OK!


这时可以restore增量备份了

[root@localhost backup]# mv /data/mysql/usr/local/mysql/data /data/mysql/usr/local/mysql/data.bak
[root@localhost backup]# mkdir /data/mysql/usr/local/mysql/data
[root@localhost backup]# innobackupex --copy-back /data/backup/2012-06-27_17-49-49

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012.  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 files in '/data/backup/2012-06-27_17-49-49'
innobackupex: back to original data directory '/data/mysql/usr/local/mysql/data/'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//xtrabackup_checkpoints'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//ib_logfile1'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//ib_logfile0'
innobackupex: Creating directory '/data/mysql/usr/local/mysql/data//performance_schema'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//performance_timers.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//setup_timers.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//rwlock_instances.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//cond_instances.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_summary_by_instance.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//mutex_instances.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//file_summary_by_event_name.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_history.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_current.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//db.opt'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_summary_by_thread_by_event_name.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//file_summary_by_instance.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//setup_instruments.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//file_instances.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//setup_consumers.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//threads.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_history_long.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//events_waits_summary_global_by_event_name.frm'
innobackupex: Creating directory '/data/mysql/usr/local/mysql/data//mysql'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_topic.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//host.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//servers.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//tables_priv.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proc.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//plugin.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//func.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//host.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//user.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//db.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_leap_second.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proxies_priv.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//slow_log.CSV'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_name.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//event.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition_type.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//columns_priv.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_category.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//general_log.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition_type.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_name.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_keyword.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_topic.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//procs_priv.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_relation.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//procs_priv.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_keyword.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_keyword.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//user.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_category.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//event.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//func.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//slow_log.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//db.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//db.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//host.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_leap_second.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_relation.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//procs_priv.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//func.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_name.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_topic.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proc.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//servers.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proc.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//general_log.CSM'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_leap_second.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//columns_priv.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//ndb_binlog_index.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//tables_priv.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//user.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proxies_priv.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//plugin.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//ndb_binlog_index.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_category.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//servers.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//tables_priv.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition_type.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//columns_priv.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//help_relation.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//ndb_binlog_index.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//proxies_priv.frm'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//general_log.CSV'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//plugin.MYI'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//event.MYD'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//slow_log.CSM'
innobackupex: Copying file '/data/mysql/usr/local/mysql/data//time_zone_transition.MYI'
innobackupex: Creating directory '/data/mysql/usr/local/mysql/data//test'

innobackupex: Starting to copy InnoDB system tablespace
innobackupex: in '/data/backup/2012-06-27_17-49-49'
innobackupex: back to original InnoDB data directory '/data/mysql/usr/local/mysql/data/'
innobackupex: Copying file '/data/backup/2012-06-27_17-49-49/ibdata1'

innobackupex: Starting to copy InnoDB log files
innobackupex: in '/data/backup/2012-06-27_17-49-49'
innobackupex: back to original InnoDB log directory '/data/mysql/usr/local/mysql/data/'
innobackupex: Finished copying back files.

120627 18:49:29  innobackupex: completed OK!
[root@localhost backup]#

 

----end----

 

参考:http://www.percona.com/doc/percona-xtrabackup/innobackupex/incremental_backups_innobackupex.html

原创粉丝点击