How to use Innobackupex
1. Full backup parameters a full backup address is fully backed up to the/data/mysql/back_up/all_testdb_20140612 directory
Innobackupex--user=root--password=123456--no-timestamp/data/mysql/back_up/all_testdb_20140612
Now the full backup directory is/data/mysql/back_up/all_testdb_20140612
2. Incremental backup
First time
SH incremental_backup.sh/data/mysql/back_up/back_up_20140601/data/mysql/back_up/all_testdb_20140612
Second time
SH incremental_backup.sh/data/mysql/back_up/back_up_20140602/data/mysql/back_up/back_up_20140601
Third time
SH incremental_backup.sh/data/mysql/back_up/back_up_20140603/data/mysql/back_up/back_up_20140602
The specific script is as follows:
Innobackupex--user=root--password=123456--no-timestamp--incremental $--incremental-basedir=$2--defaults-file=/ Etc/my.cnf
The specific directory is as follows:
Drwxr-xr-x. 7 root root 4096 June 14:29 all_testdb_20140612//full-volume backup address
Drwxr-xr-x. 7 root root 4096 June 14:31 back_up_20140601//First time backup address
Drwxr-xr-x. 7 root root 4096 June 14:32 back_up_20140602//secondary backup address
Drwxr-xr-x. 7 root root 4096 June 14:32 back_up_20140603//Third backup address
Option--incremental is specified as an incremental backup--incremental-basedir option is the directory that specifies the last incremental backup (or the full backup if it is the first incremental backup).
3. Restore
The restore operation for an incremental backup is a bit different from a full restore, and you must first use--apply-log--redo-only to operate on the full backup directory and all the incremental backup directories, and then you can restore the operation as if you were restoring the full backup.
Apply-log redo-only operations for each backup directory (including full backups)
Innobackupex--apply-log--redo-only/data/mysql/back_up/all_testdb_20140612--user=root--password=123456
Innobackupex--apply-log--redo-only/data/mysql/back_up/all_testdb_20140612--incremental-dir=/data/mysql/back_up /back_up_20140601--user=root--password=123456
Innobackupex--apply-log--redo-only/data/mysql/back_up/all_testdb_20140612--incremental-dir=/data/mysql/back_up /back_up_20140602--user=root--password=123456
Innobackupex--apply-log--redo-only/data/mysql/back_up/all_testdb_20140612--incremental-dir=/data/mysql/back_up /back_up_20140603--user=root--password=123456
The following is the same as when restoring a full backup
/etc/init.d/mysqld stop
Delete the original data
rm-rf/var/lib/mysql/*
To generate new data
Innobackupex--copy-back/data/mysql/back_up/all_testdb_20140612
Chown-r mysql.mysql/var/lib/mysql/
/etc/init.d/mysqld start