Xtrabackup's Innobackupex Backup recovery

Source: Internet
Author: User

Original: http://ourlinux.blog.51cto.com/274624/844854

Installation Configuration Xtrabackup
First look at how to install the Xtrabackup, the simplest way to install is to use the RPM package, but you want to use the source code mode installation, its installation is a bit odd, because it is installed in the MySQL source code patched build way. It is relatively flexible to use the binary package installation method.
Shell> Mkdir/usr/local/xtrabackup
Shell> TAR-ZXVF Xtrabackup-1.6.tar.gz–c/usr/local/xtrabackup
Shell>cd/usr/local/xtrabackup/bin
Shell>ln–s innobackupex-1.5.1 Innobackupex

To configure environment variables:
Shell>export path= $PATH:/usr/local/xtrabackup/bin
If you wish to have permanent effect, you can add it to
echo "Export path= $PATH:/usr/local/xtrabackup/bin" >>/etc/profile
Source/etc/profile

To modify the MySQL configuration file:
Shell> vi/etc/my.cnf
Add or modify: DataDir =/usr/local/mysql/var (Database directory)
Special Note: Default_table_type = InnoDB (must be changed, otherwise the incremental backup is unsuccessful)

After a few days of testing, the document can finally be shared with you. Using Xtrabackup to back up and restore MySQL database very quickly is the first choice for MySQL DBA. Xtrabackup is a innodb to do data backup tools, Support Online hot backup (backup without affecting the data read and write), is a commercial backup tool InnoDB hotbackup a good alternative. Xtrabackup has two main tools: Xtrabackup, Innobackupex Xtrabackup can only back up InnoDB and xtradb two kinds of data tables, support Online hot backup, do not lock the table The Innobackupex encapsulates the xtrabackup and can back up MyISAM data tables, and if you have InnoDB and MyISAM storage engines in your database, you can only use Innobackupex backup, here's a simple online script
#!/bin/bash
User=root
password=123456
Date >/data/scripts/backup.log
echo "Begin backup-------------------------------" >>/data/scripts/backup.log
Find/data/mysql/backups-mtime +7 |xargs RM-RF
/usr/bin/innobackupex--defaults-file=/opt/mysql5/my.cnf--user= $USER--password= $PASSWORD--databases= "Test1 test2 "/data/mysql/backups >>/data/scripts/backup.log 2>&1
echo "End Backup-------------------------------" >>/data/scripts/backup.log
Date >>/data/scripts/backup.log

Mail-s "Backup Passport report" "[Email protected]" </data/scripts/backup.log
Exit 0

Here is the recovery script:
#!/bin/bash
User=root
password=123456
/etc/init.d/mysql stop
/usr/bin/innobackupex-1.5.1--apply-log--defaults-file=/opt/mysql5/my.cnf--user= $USER--password= $PASSWORD/data/ mysql/backups/passportdb/' Date +%y-%m-%d '
Rm-rf/opt/mysql5/var/test1
Rm-rf/opt/mysql5/var/test2
Rm-f/opt/mysql5/var/ibdata1
Rm-f/OPT/MYSQL5/VAR/IB_LOGFILE0
Rm-f/opt/mysql5/var/ib_logfile1
Cd/data/mysql/backups
Tar zcvf ' Date +%y-%m-%d '. tgz ' Date +%y-%m-%d '
Rm-rf ' date-d -30day +%y-%m-%d '. tgz
Cp-r/data/mysql/backups/' Date +%y-%m-%d '/ib*/opt/mysql5/var/
Cp-r/data/mysql/backups/' Date +%y-%m-%d '/test1/opt/mysql5/var/
Cp-r/data/mysql/backups/' Date +%y-%m-%d '/test2/opt/mysql5/var/
rm-rf/data/mysql/backups/' Date +%y-%m-%d '/*
Chown-r Mysql.mysql/opt/mysql5/var/test1
Chown-r Mysql.mysql/opt/mysql5/var/test2
Chown mysql.mysql/opt/mysql5/var/ib*
/etc/init.d/mysql start

Restore the time after the execution of/usr/bin/innobackupex-1.5.1--apply-log, the direct copy can be, do not use the/usr/bin/innobackupex-1.5.1--copy-back command. If you use the/usr/bin/innobackupex-1.5.1--copy-back command, you will be reported original data directory is not empty! At/usr/local/xtrabackup/bin/innobackupex line 538. The recovered directory must be empty. After checking the official website, this is a bug of Xtrabackup.
InnobackupexDid not check this MySQL DataDir was empty before–copy-backwas run. With this bug fix,InnobackupexWould now error out of the–copy-backOperation if the destination is not empty, avoiding potential data loss or a Strang combination of a restored backup and P revious data. Bug fixed: #737569 (Valentine Gostev)

There are many articles on the Internet to restore use
/usr/bin/innobackupex-1.5.1--apply-log Then
/usr/bin/innobackupex-1.5.1--copy-back, do they restore the directory are empty directory, or the same.

Xtrabackup Innobackupex Backup Recovery Details (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.