Percona-XtraBackup系列三:增量备份恢复

1:创建测试表和测试库
如果需要快速建立测试表和库的话,参考之前写的这篇博客:
http://www.cnblogs.com/xiaoit/p/3376685.html
create database backup_test;

  

CREATE TABLE `backup` (  
 `id` int(11) NOT NULL AUTO_INCREMENT ,  
 `name` varchar(20) NOT NULL DEFAULT '' ,  
 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,  
 `del` tinyint(1) NOT NULL DEFAULT '0',  
 PRIMARY KEY (`id`)  
) ENGINE=myisam DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;  

 

mysql> INSERT INTO backup (name) VALUES ('Hi'),('Hi');

  

2:全备份

innobackupex --defaults-file=/etc/my.cnf --user=root --password='ge0513' --slave-info  /root/

 

3:再次插入数据

INSERT INTO backup (name) VALUES ('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1'),('Hi1');

 

4:增量备份

innobackupex --defaults-file=/etc/my.cnf --user=root --password='ge0513' --incremental-basedir=/root/2015-05-25_20-54-39/ --incremental /root/

  

150525 20:56:05  innobackupex: completed OK!
[root@localhost ~]# ls
2015-05-25_20-54-39  526.sql  anaconda-ks.cfg  Documents  install.log         Music     Public    sql.sql    Videos
2015-05-25_20-56-00  all.sql  Desktop          Downloads  install.log.syslog  Pictures  software  Templates
[root@localhost ~]# cd 2015-05-25_20-56-00/
[root@localhost 2015-05-25_20-56-00]# ls
backup-my.cnf  ibdata1.delta  mysql               test                    xtrabackup_checkpoints  xtrabackup_logfile
dbmm           ibdata1.meta   performance_schema  xtrabackup_binlog_info  xtrabackup_info
[root@localhost 2015-05-25_20-56-00]# cat xtrabackup_checkpoints 
backup_type = incremental
from_lsn = 68178003
to_lsn = 68201658
last_lsn = 68201658
compact = 0

  

 

5:进入备份目录查看备份信息

cat xtrabackup_checkpoints

  

6:增量还原

 

innobackupex --defaults-file=/etc/my.cnf --user=root --password='ge0513' --apply-log --redo-only /root/2015-05-25_20-54-39/

  

innobackupex --defaults-file=/etc/my.cnf --user=root --password='ge0513'  --redo-only /root/2015-05-25_20-56-00/ --incremental-dir=/root/2015-05-25_20-56-00/

  


                            

你可能感兴趣的:(backup)