Step two, view the data
mysql> use Larrydb;
Database changed
mysql> select * from class;
+------+-------+
| cid | CNAME |
+------+-------+
| 1 | Linux |
| 2 | Dab |
| 3 | Devel |
+------+-------+
3 rows in Set (0.00 sec)
mysql> select * from Stu;
+------+----------+------+
| Sid | sname | CID
| +------+----------+------+
| 1 | larry007 | 1 |
+------+----------+------+
1 row in Set (0.00 sec)
Step three, update the data
mysql> INSERT INTO Stu values (2, ' larry02 ', 1);
Query OK, 1 row Affected (0.00 sec)
mysql> select * from Stu;
+------+----------+------+
| Sid | sname | CID
| +------+----------+------+
| 1 | larry007 | 1 |
| 2 | Larry02 | 1 |
+------+----------+------+
2 rows in Set (0.00 sec)
Step fourth, incremental backups, full and first incremental backups, so there are two backup folders. Every incremental backup we have is for the last backup.
#--incremental: Incremental backup folder
#--incremental-dir: for which incremental backup
[root@serv01 databackup]# Innobackupex--user=root- password=123456--incremental/databackup/--incremental-dir/databackup/2013-09-10_22-12-50/
InnoDB Backup Utility V1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and
Percona Inc 2009-2012. All Rights Reserved.
..... Innobackupex:backup created in directory '/databackup/2013-09-10_22-15-45 '
innobackupex:mysql binlog position: FileName ' mysql-bin.000004 ', Position 353
130910 22:16:04 innobackupex:completed
[ROOT@SERV01 databackup]# ll Total
8
drwxr-xr-x 9 root root 4096 Sep 22:13 2013-09-10_22-12-50 drwxr-x
R-x. 9 root 4096 Sep 10 22:16 2013-09-10_22-15-45
Step Fifth, insert the data again
mysql> INSERT into Stu values (3, ' larry03 ', 1);
Query OK, 1 row Affected (0.00 sec)
mysql> select * from Stu;
+------+----------+------+
| Sid | sname | CID
| +------+----------+------+
| 1 | larry007 | 1 |
| 2 | Larry02 | 1 |
| 3 | Larry03 | 1 |
+------+----------+------+
3 rows in Set (0.00 sec)
Step sixth, incremental backup again
[ROOT@SERV01 databackup]# ll Total
8
drwxr-xr-x 9 root root 4096 Sep 22:13 2013-09-10_22-12-50 drwxr-x
R-x. 9 root 4096 Sep 22:16 2013-09-10_22-15-45
[root@serv01 databackup]# innobackupex--user=root---password=1234 --incremental/databackup/--incremental-dir/databackup/2013-09-10_22-15-45/
Step seventh, insert the data again
mysql> INSERT into Stu values (4, ' larry04 ', 1);
Query OK, 1 row Affected (0.00 sec)
mysql> select * from Stu;
+------+----------+------+
| Sid | sname | CID
| +------+----------+------+
| 1 | larry007 | 1 |
| 2 | Larry02 | 1 |
| 3 | Larry03 | 1 |
| 4 | LARRY04 | 1 |
+------+----------+------+
4 rows in Set (0.00 sec)
Step eighth, incremental backup again. Full-time, three incremental backups, so there are four backup folders
[Root@serv01 databackup]# Innobackupex--user=root--password=123456--incremental/databackup/--incremental-dir/ databackup/2013-09-10_22-19-21/
[root@serv01 databackup]# ll Total
drwxr-xr-x. 9 root 4096 Sep 22:13 2013-09-10_22-12-50
drwxr-xr-x 9 root 4096 Sep 22:16 2013-09-10_22-15-45 drwxr-xr-x
. 9 Root Ro OT 4096 Sep 22:19 2013-09-10_22-19-21
drwxr-xr-x. 9 root 4096 Sep 10 22:22 2013-09-10_22-21-42
Step nineth, simulate data loss
mysql> drop database larrydb;
Query OK, 2 rows affected (0.02 sec)
The tenth step is to check all the data. You can see that incremental backups and fully-prepared files take up a large amount of disk size, with a clear total disk space footprint and incremental backups taking up less disk space
[Root@serv01 databackup]# Innobackupex--apply-log--redo-only/databackup/2013-09-10_22-12-50/
InnoDB Backup Utility V1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and
Percona Inc 2009-2012. All Rights Reserved.
..... xtrabackup:starting shutdown with Innodb_fast_shutdown = 1
130910 22:23:35 innodb:starting shutdown ...
130910 22:23:36 innodb:shutdown completed log sequence number 2098700 130910 22:23:36 innobackupex : Completed ok!
[Root@serv01 databackup]# du-sh. *
22M./2013-09-10_22-12-50
1.5M ./2013-09-10_22-15-45
1.5M ./2013-09-10_22-19-21
1.5M ./2013-09-10_22-21-42
The 11th step is to merge the incremental backup data for the first time into a full backup
[Root@serv01 databackup]# Innobackupex--apply-log--redo-only--incremental/databackup/2013-09-10_22-12-50/-- incremental-dir=/databackup/2013-09-10_22-15-45/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and
Percona Inc 2009-2012. All Rights Reserved.
..... Innobackupex:copying '/databackup/2013-09-10_22-15-45/hello/db.opt ' to '/databackup/2013-09-10_22-12-50/hello/ Db.opt '
130910 22:32:26 innobackupex:completed ok!
The 12th step is to merge the incremental backup data for the second time into a full backup
[Root@serv01 databackup]# Innobackupex--apply-log--redo-only--incremental/databackup/2013-09-10_22-12-50/-- incremental-dir=/databackup/2013-09-10_22-19-21/
The 13th step is to merge the incremental backup data for the third time into a full backup
[Root@serv01 databackup]# Innobackupex--apply-log--redo-only--incremental/databackup/2013-09-10_22-12-50/-- incremental-dir=/databackup/2013-09-10_22-21-42/
14th step, restore need to stop MySQL, so we stopped MySQL
[Root@serv01 databackup]#/etc/init.d/mysqld Stop
error! MySQL server PID file could not is found!
[Root@serv01 databackup]# pkill-9 MySQL
The 15th step is to recover the data. Note that the folder specified here is 2013-09-10_22-12-50
[Root@serv01 databackup]# Innobackupex--copy-back/databackup/2013-09-10_22-12-50/innodb Backup Utility V1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona Inc 2009-2012.
All Rights Reserved.
This software was 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!". Original Data directory is not empty!
At/usr/bin/innobackupex Line 571. #报以上错需要删除数据目录下的东西 [root@serv01 data]# pwd/usr/local/mysql/data [root@serv01 data]# ls game ib_logfile0 MySQL mysql-bin.000003 performance_schema Test Hello ib_logfile1 mysql-bin.000001 mysql-bin.000004 serv01.host.com . err Xtrabackup_binlog_pos_innodb ibdata1 mnt mysql-bin.000002 mysql-bin.index serv01.host.com.pid [root@se RV01 data]# RM-RF * #再次恢复数据 and change the owner and group of the database data directory [ROOT@SERV01 databackup]# Innobackupex--copy-back/databackup/2013-09-10_22-12-50/[root@serv01 data]# ll Total 18464 drwxr-xr-x. 2 root root 4096 Sep 22:37 game drwxr-xr-x. 2 root 4096 Sep 22:37 hello-rw-r-----. 1 root root 18874368 Sep 22:33 ibdata1 drwxr-xr-x. 2 root root 4096 Sep 22:37 larrydb drwxr-xr-x. 2 root root 4096 Sep 22:37 mnt drwxr-xr-x. 2 root 4096 Sep 22:37 MySQL drwxr-xr-x. 2 root root 4096 Sep 22:37 Performance_schema drwxr-xr-x. 2 root 4096 Sep 22:37 test-rw-r--r--. 1 root Sep 22:37 xtrabackup_binlog_pos_innodb [root@serv01 data]# chown mysql.mysql/usr/local/mysql/d
ata/-R
Step 16th, start the service
[Root@serv01 data]#/etc/init.d/mysqld start
starting MySQL. success!
Step 17th, log in to the database, and then view the data