Second, Innobackupex and Xtrabackup backup detailed
Note: Innobackupex will determine the MySQL data location according to the/ET/MY.CNF.
1. Normal Backup:
Innobackupex [--defaults-file=/etc/my.cnf]--user=root [--host=192.168.1.52] [--password=xxx] [--port=3306]/data/ Back_data/2>/data/back_data/1.log
The backup directory is/data/back_data/, where the 2>/data/back_data/1.log is to redirect output information from the backup process to 1.log
Innobackupex-1.5.1–slave-info .....
–slave-info will record the replication point of the replication master log, making it easier to replicate again. (used in backup from machine)
Files after backup:
xtrabackup_binlog_info-Store binlog information. (Binlog requires a separate copy of the backup, if necessary binlog)
Xtrabackup_checkpoints-stores the starting and ending positions of the backup.
Recovery:
First, deactivate the database, and then delete all the database files in the database directory.
Cd/data/mysql_data
RM-RF * # Delete all files in the data directory
innobackupex-1.5.1--user=root--apply-log/data/back_data/2010-10-26_16-09-37 # Application Log
innobackupex-1.5.1--user=root--copy-back/data/back_data/2010-10-26_16-09-37
The default innobackupex-1.5.1 will store the binary log information in the file Xtrabackup_binlog_info (easy to do slave).
Cd/data
Chown-r Mysql:mysql mysql_data/
Restart the MySQL service
2. Package (Tar) Backup:
innobackupex-1.5.1--user=root [--password=xxx]--stream=tar/data/back_data/2/2>/data/back_data/2.log 1>/ Data/back_data/2.tar
Restores:
#cd/data/back_data/2/
#tar IXVF 2.tar
# ls
2.tar backup-my.cnf ibdata1 ibdata2 mablevi mysql xtrabackup_binlog_info xtrabackup_checkpoints xtrabackup_logfile
Preparing to restore
# innobackupex-1.5.1--user=xxx [--password=xxx]--apply-log/data/back_data/
......
Innobackupex:completed ok!
Delete all files in the data directory
rm-rf/data/mysql_data/*
Copy:
# innobackupex-1.5.1--user=xxx [--password=xxx]--copy-back/data/back_data/
......
Innobackupex:completed ok!
Cd/data
Chown-r Mysql:mysql mysql_data/
Restart the MySQL service
3. Compressed (tar gzip) backup
innobackupex-1.5.1--user=root [--password=xxx]--stream=tar
/data/back_data/2/2>/data/back_data/2.log | gzip >/data/back_data/2.tar.gz
The pipeline is used here | To use innobackupex-1.5.1 as the standard input for gzip. Recovery, you only need to use TAR-IZXVF to extract the corresponding files, the operation is completely the same as normal backup.
Restores:
After using TAR–IZXVF to extract the corresponding files, the operation is completely the same as normal backup.
#cd/data/back_data/2/
#tar IXVF 2.tar
# ls
BACKUP-MY.CNF ibdata1 ibdata2 mablevi mysql xtrabackup_binlog_info xtrabackup_checkpoints xtrabackup_logfile
Prepare for restore:
# innobackupex-1.5.1--user=xxx [--password=xxx]--apply-log/data/back_data/2/
......
Innobackupex:completed ok!
Delete all files in the data directory
rm-rf/data/mysql_data/*
# innobackupex-1.5.1--user=xxx [--password=xxx]--copy-back/data/back_data/2/
Cd/data
Chown-r Mysql:mysql mysql_data/
Restart the MySQL service
———————————————————————————————————————
Xtrabackup Backup and Recovery
Backup:
Xtrabackup--defaults-file=/etc/my.cnf--backup--target-dir=/data/back_data/
Recovery:
Need to perform two times Xtrabackup–prepare
Xtrabackup--defaults-file=/etc/my.cnf--prepare--target-dir=/data/back_data/
Xtrabackup--defaults-file=/etc/my.cnf--prepare--target-dir=/data/back_data/
Note that Xtrabackup only backs up data files and does not back up the data table structure (. frm), so when you use Xtrabackup recovery, you must have a corresponding table structure file (. frm).
Incremental backups:
1. Full-scale backup
Xtrabackup--defaults-file=/etc/my.cnf--backup--target-dir=/data/back_data/
2. Incremental backup
Xtrabackup--defaults-file=/etc/my.cnf--backup--target-dir=/data/back_data_inc/--incremental-
basedir=/data/back_data/
In a directory where incremental backups are made, the data files are terminated with the. Delta. An incremental backup backs up only the page that has been modified since the last full backup, so incremental backups take up only a small amount of space. Incremental backups can be incremental on the basis of incremental backups.
Incremental backup recovery:
We need to do a prepare operation on a full, incremental backup individually.
Xtrabackup--defaults-file=/etc/my.cnf--prepare--target-dir=/data/back_data/2010-10-26_16-09-37
Xtrabackup--prepare--target-dir=/data/back_data/2010-10-26_16-09-37--incremental-
Dir=/data/back_data_inc
Xtrabackup--prepare--target-dir=/data/back_data/#这一步不是必须的
In this way, the data files under the/data/back_data/can be directly placed in your MySQL data directory, restore the data.
Again, Xtrabackup only backs up the InnoDB data file, the table structure is not backed up, so when you recover, you must have the corresponding table structure file (. frm).
rm-rf/data/mysql_data/ib*
Cp-i/data/back_data/2010-10-26_16-09-37/ib*/data/mysql_data/
Cd/data
Chown-r Mysql:mysql mysql_data/
2.innobackupex combined with Xtrabackup
First, Innobackupex full backups:
Innobackupex--user=root/data/back_data/2>/data/back_data/1.log #会生成一个时间文件夹, if this is 2010-10-29_15-57-44
Then, Xtrabackup do an incremental backup:
Xtrabackup--defaults-file=/etc/my.cnf--backup--TARGET-DIR=/DATA/BACK_DATA_INC/4--incremental-basedir=/data/ Back_data/2010-10-29_15-57-44
Recovery:
First deactivate the database, back up the binary log (if any), and then delete all the database files in the database directory.
Cd/data/mysql_data
RM-RF * # Delete all files in the data directory
Restore full-Volume backups:
Innobackupex--user=root--apply-log/data/back_data/2010-10-29_15-57-44 # Application Log
Innobackupex--user=root--copy-back/data/back_data/2010-10-29_15-57-44 # Copy files
To restore an incremental backup:
Xtrabackup--prepare--target-dir=/data/back_data/2010-10-29_15-57-44--INCREMENTAL-DIR=/DATA/BACK_DATA_INC/5
Cd/data
Chown-r Mysql:mysql mysql_data/
Restart the MySQL service.