您好,登录后才能下订单哦!
一、备份用户创建
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。