Xtrabackup是一個對InnoDB作數據備份的工具,支持在線熱備份。mysql
1.安裝percona倉庫sql
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpmvim
2.安裝xtrabackup工具
yum install percona-xtrabackup -yrem
3.建立備份用戶及設置權限get
CREATE USER ‘bkpuser’@'localhost' IDENTIFIED BY 'password';sed
GRANT RELOAD,LOCK TABLES,PROCESS,REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost';配置
FLUSH PRIVILEGES;權限
4.配置xtrabackupim
vim /root/.my.cnf
[xtrabackup]
user=bkpuser
password=password
5.執行一次全備份
xtrabackup --backup --target-dir=/data/backups/mysql/full_backup
6.在全備份的基準上執行第一次增量備份
xtrabackup --backup --target-dir=/data/backups/mysql_increase1 --incremental-basedir=/data/backups/mysql/full_backup
7.日後的每一次增量備份都以上一次增量備份爲基準
xtarbackup --backup --target-dir=/data/backups/mysql_increase2 --incremental-basedir=/data/backups/mysql_increase2
8.自動備份寫腳本