Xtrabackup has two main tools: xtrabackup and innobackupex.
(1) xtrabackup can only back up InnoDB and XtraDB data tables, but cannot back up MyISAM data tables.
(2) innobackupex-1.5.1 encapsulates xtrabackup, which is a script encapsulation, so innodb and myisam can be backed up at the same time, but a read lock is needed when processing myisam
(3) Help: http://www.percona.com/docs/wiki/percona-xtrabackup:start
Environment: CentOS 5.4,xtrabackup-1.6.tar.gz
1. First download from http://www.percona.com/
Wget http://www.percona.com/downloads/XtraBackup/XtraBackup-1.6/Linux/binary/i686/xtrabackup-1.6.tar.gz
2. Check whether the Mysql version is installed on the server. If not, install mysql.
Datadir =/var/lib/mysql must exist in my. cnf.
3. Start to install xtrabackup
1) decompress
Cd/qeedoodb/setup
Tar zxvf xtrabackup-1.6.tar.gz
2) copy the innobackupex, xtrabackup, and xtrabackup_51 tools to/usr/bin.
Cp/qeedoodb/setup/xtrabackup-1.6/bin/innobackupex/usr/bin/innobackupex
Cp/qeedoodb/setup/xtrabackup-1.6/bin/xtrabackup/usr/bin/xtrabackup
Cp/qeedoodb/setup/xtrabackup-1.6/bin/xtrabackup_51/usr/bin/xtrabackup_51
4. Back up and compress the package
Innobackupex -- user = root -- password = 123456 -- defaults-file =/etc/my. cnf -- database = zztx -- stream = tar/data/back_data/2>/data/back_data/zztx. log | gzip 1>/data/back_data/zztx.tar.gz
Note:
-- Database = zztx back up the zztx database separately. If this parameter is not added, the full database is backed up.
2>/data/back_data/zztx. log: Write the output information to the log.
1>/data/back_data/zztx.tar.gz package, compress, and store it in this file
Here, you can write a script for backup (backup. sh)
#! /Bin/sh
Echo "Start backup..." 'date'
Log = zztx01 _ 'date + % y % m % d % H % M'. log
Str = zztx01 _ 'date when policyymm1_d1_hsf-m'.tar.gz
Innobackupex -- user = root -- password = 123456 -- defaults-file =/etc/my. cnf -- database = zztx -- stream = tar/data/back_data/2>/data/back_data/$ log | gzip 1>/data/back_data/$ str
Echo "backup completed..." 'date'
5. Restore data
1) stop the database first: service mysqld stop
2) decompress tar-izxvf zztx.tar.gz-C/data/back_data/db/(without db, mkdir/data/back_data/db/is required /)
3) Restore innobackupex -- user = root -- password -- defaults-file =/etc/my. cnf -- apply-log/data/back_data/db/(the command for the -- apply-log option is to start the mysql service on a backup)
Innobackupex -- user = root -- password -- defaults-file =/etc/my. cnf -- copy-back/data/back_data/db/(-- copy-back option command copy data, index, log to my. the initial position specified in the cnf file .)
4) Attach chown-R mysql. mysql/var/lib/mysql /*
5) restart Database service mysqld restart
6) Delete junk cd/var/lib/mysql/& rm xtrabackup *
Go to the database and check everything. OK ~