您好,登錄后才能下訂單哦!
一、備份用戶創建
CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 'bkpuser';
GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON . TO 'bkpuser'@'localhost';
FLUSH PRIVILEGES;
二、備份
-- 執行備份 (不帶時間戳)
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --socket=/data/mysql/db_test/mysql.sock --parallel=8 --slave-info --no-timestamp /data/backups/full
-- 執行備份 (帶時間戳)
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --socket=/data/mysql/db_test/mysql.sock --parallel=8 --slave-info /data/backups/full
-- 執行備份 (具體某個庫)
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --socket=/data/mysql/db_test/mysql.sock --databases=t1 --parallel=8 --slave-info /data/backups/full
-- 執行備份 (增量備份,全備基礎上進行增量備份)
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --socket=/data/mysql/db_test/mysql.sock --incremental-basedir=/data/backups/full/2018-05-02_13-42-59/ --incremental /data/backups/inc
-- 執行備份 (增量備份,增備基礎上進行增量備份)
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --socket=/data/mysql/db_test/mysql.sock --incremental-basedir=/data/backups/inc/2018-05-02_13-44-24/ --incremental /data/backups/inc
三、恢復
-- 全量恢復
rm -rf /data/mysql/db_test/data/ #刪除數據目錄
rm -rf /data/mysql/db_test/ulog/ #刪除數據目錄
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --copy-back /data/backups/full/2018-05-02_13-42-59/
-- 修改文件夾權限
chown -R mysql:mysql /data/mysql/db_test/data
chown -R mysql:mysql /data/mysql/db_test/ulog
-- 增量恢復(全備基礎上做增量恢復)
-- 其實就是將全備和增備合并在一起,然后進行恢復
rm -rf /data/mysql/db_test/data/ #刪除數據目錄
rm -rf /data/mysql/db_test/ulog/ #刪除數據目錄
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/ --incremental-dir=/data/backups/inc/2018-05-02_13-44-24
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --copy-back /data/backups/full/2018-05-02_13-42-59/
-- 增量恢復(增備基礎上做增量恢復)
-- 將全備+增備1+增備2全部放一起恢復
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/ --incremental-dir=/data/backups/inc/2018-05-02_13-44-24
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/ --incremental-dir=/data/backups/inc/2018-05-02_13-45-45
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --apply-log --redo-only /data/backups/full/2018-05-02_13-42-59/
/usr/local/xtrabackup/bin/innobackupex --defaults-file=/data/mysql/db_test/conf/test.cnf --user=bkpuser --password=bkpuser --copy-back /data/backups/full/2018-05-02_13-42-59/
-- 修改文件夾權限
chown -R mysql:mysql /data/mysql/db_test/data
chown -R mysql:mysql /data/mysql/db_test/ulog
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。