1 搭建測試環境
mysql> show tables;
+----------------+
| tables_in_test |
| sbtest |
1 row in set (0.01 sec)
2 全量備份
[root@rac3 mysql]# innobackupex --defaults-file=/etc/my.cnf --user=root /opt/mysql/backup/base
3 建立新的表
mysql> create table t1 as select * from sbtest;
mysql> create table t2 as select * from sbtest limit 1000;
mysql> create table t3 as select * from sbtest limit 1000;
| t1 |
| t2 |
| t3 |
4 rows in set (0.00 sec)
4 增量備份:
[root@rac3 mysql]# innobackupex --defaults-file=/etc/my.cnf --user=root --incremental --incremental-basedir=/opt/mysql/backup/base /opt/mysql/backup/delta
5 關閉資料庫,删除資料
[root@rac3 mysql]# service mysql stop
shutting down mysql. [确定]
[root@rac3 mysql]#rm -fr data
6 恢複資料
全量恢複:
[root@rac3 mysql]# innobackupex --defaults-file=/etc/my.cnf --user=root --apply-log --redo-only /opt/mysql/backup/base/2011-12-11_20-47-06
增量恢複:
[root@rac3 mysql]# innobackupex --defaults-file=/etc/my.cnf --user=root --apply-log --redo-only /opt/mysql/backup/base/2011-12-11_21-12-46 --incremental-dir=/opt/mysql/backup/delta/2011-12-11_21-25-50
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!".
111211 21:32:15 innobackupex: starting ibbackup with command: xtrabackup_55 --defaults-file="/etc/my.cnf" --prepare --target-dir=/opt/mysql/backup/base/2011-12-11_21-12-46 --apply-log-only --incremental-dir=/opt/mysql/backup/delta/2011-12-11_21-25-50
xtrabackup_55 version 1.6.3 for percona server 5.5.9 linux (x86_64) (revision id: 292)
incremental backup from 8809430318 is enabled.
xtrabackup: cd to /opt/mysql/backup/base/2011-12-11_21-12-46
xtrabackup: this target seems to be already prepared.
xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(8810280564)
xtrabackup: page size for /opt/mysql/backup/delta/2011-12-11_21-25-50/ibdata1.delta is 16384 bytes
applying /opt/mysql/backup/delta/2011-12-11_21-25-50/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 = /opt/mysql/backup/delta/2011-12-11_21-25-50
xtrabackup: innodb_log_files_in_group = 1
xtrabackup: innodb_log_file_size = 2097152
111211 21:32:15 innodb: using linux native aio
xtrabackup: starting innodb instance for recovery.
xtrabackup: using 104857600 bytes for buffer pool (set by --use-memory parameter)
111211 21:32:15 innodb: the innodb memory heap is disabled
111211 21:32:15 innodb: mutexes and rw_locks use gcc atomic builtins
111211 21:32:15 innodb: compressed tables use zlib 1.2.3
111211 21:32:15 innodb: warning: innodb_file_io_threads is deprecated. please use innodb_read_io_threads and innodb_write_io_threads instead
111211 21:32:15 innodb: initializing buffer pool, size = 100.0m
111211 21:32:15 innodb: completed initialization of buffer pool
111211 21:32:15 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!
111211 21:32:15 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 321824, file name ./mysql-bin.000001
[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
111211 21:32:16 innodb: starting shutdown...
111211 21:32:16 innodb: shutdown completed; log sequence number 8810280564
111211 21:32:16 innobackupex: completed ok!
拷貝檔案
[root@rac3 test]# innobackupex --defaults-file=/etc/my.cnf --user=root --copy-back /opt/mysql/backup/base/2011-12-11_21-12-46
重新開機mysql
[root@rac3 mysql]# service mysql start
starting mysql... [确定]
7 進行确認!
mysql> use test;
database changed
mysql> show tables;
2 rows in set (0.00 sec)
<b>通過以上資訊可以看到innobackupex 不能備份全量備份之後到增量備份之前的建立資料對象。</b>