当前位置:网站首页>xtrabackup的备份还原
xtrabackup的备份还原
2022-06-25 22:04:00 【匿称s】
Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具MySQL Enterprise Backup(meb)的一个很好的替代品。
xtrabackup有两个主要的工具:innobackupex和xtrabackup,xtrabackup只能备份InnoDB和XtraDB数据表,innobackupex封装了xtrabackup,可以备份MyISAM数据表。
yum install perl-DBD-MySQL.x86_64yum install perl-Time-HiRes.x86_64wget http://www.percona.com/downloads/XtraBackup/XtraBackup-2.2.3/binary/redhat/6/x86_64/percona-xtrabackup-2.2.3-4982.el6.x86_64.rpmrpm -ivh percona-xtrabackup-2.2.3-4982.el6.x86_64.rpm (如果提示版本不对的情况下请到官方网站查找相应的版本)整个库进行备份
innobackupex --defaults-file=/etc/my.cnf --user=root --password=db1245789 --databases=erp /opt/backup/
增量备份
innobackupex --defaults-file=/etc/my.cnf --user=root --password=roo t--databases="erp erp2" --incremental --incremental-basedir=/opt/backup/2017-02-17_07-56-57/ /opt/backup/
整个库进行备份并打成流包
innobackupex --defaults-file=/etc/my.cnf --user=root --password=root --databases=erp --stream=tar /opt/backup/ > /opt/backup/dbbackup20110809.tar
常用命令
innobackupex使用方法
完整的选项使用请执行innobackupex –help,这里只介绍使用常用的选项进行完整备份及增量备份和还原。
innobackupex Options 这里只对常用参数进行描述
–defaults-file 数据库的配置文件路径,感觉本地备份不写也可以,远程没测试过。
–apply-log 准备在一个备份上启动mysql服务。
–copy-back 从备份目录拷贝数据,索引,日志到my.cnf文件里规定的初始位置。
–no-timestamp 创建备份时不自动生成时间目录,可以自定义备份目录名例如: /backups/mysql/base
–databases 用于指定要备份的数据库, 多个库文件使用方法: “database1 database2″
–incremental 在全备份的基础上进行增量备份,后跟增量备份存贮目录路径
–incremental-basedir=DIRECTORY 增量备份所需要的全备份路径目录或上次做增量备份的目录路径
–incremental-dir=DIRECTORY 增量备份存贮的目录路径
–redo-only 用于准备增量备份内容把数据合并到全备份目录,配合–incremental-dir 增量备份目录使用。
–force-non-empty-directories 如果是特定库备份还原,不需要删掉整个mysql目录,只是特定库的及相关文件就可以,还原时加上此参数就不会报错。
其他具体参数可以参考:http://www.percona.com/doc/percona-xtrabackup/2.1/innobackupex/innobackupex_option_reference.html
还原:
7 8 9 10 11 12 13 14 15 16 17 18 19 | |
查看恢复的数据库
二、指定数据库
备份:
假如我们要备份centos和aabb数据库。
innobackupex --user=root --password=root --defaults-file=/etc/mysql/my.cnf --databases="centos aabb" /data/mysql_backup/
这样就会在/data/mysql_backup生成一个带时间的目录,如果不需要带时间,可以使用选项–no-timestamp。
如果想备份成压缩文件,可以使用如下语句:
innobackupex --user=root --password=root --defaults-file=/etc/mysql/my.cnf --databases="centos aabb" --no-timestamp --stream=tar ./ | gzip - > centos-aabb.bz.tar.gz |
还原:
假如完整备份的路径为/data/mysql_backup/full_backup,如果完整备份是压缩文件,需要先解压再还原。
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | service mysql stop
rm -rf /var/lib/mysql/ibdata*
rm -rf /var/lib/mysql/ib_logfile*
rm -rf /var/lib/mysql/centos
rm -rf /var/lib/mysql/aabb
innobackupex --apply-log /data/mysql_backup/centos_aabb_full_backup
innobackupex --copy-back --defaults-file=/etc/mysql/my.cnf /data/mysql_backup/centos_aabb_full_backup
chown -R mysql:mysql /var/lib/mysql
service mysql start |
边栏推荐
- Download the latest V80 version of Google Chrome
- Rk3568+ Hongmeng industrial control board industrial gateway video gateway solution
- YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
- Run the dronekit flight control application on Shumei faction under px4-jmavsim software simulation environment
- WordPress
- C. Yet Another Card Deck-Educational Codeforces Round 107 (Rated for Div. 2)
- What is Unified Extensible Firmware Interface (UEFI)?
- B. Box Fitting-CodeCraft-21 and Codeforces Round #711 (Div. 2)
- 二进制、16进制、大端小端
- A. Balance the Bits--Codeforces Round #712 (Div. 1)
猜你喜欢

Audio basics and PCM to WAV

Architecture part -- the use of UMI framework and DVA

二叉排序树

C# IO Stream 流(一)基础概念_基本定义

idea 查看单元测试覆盖率

Hbuilderx uses the gaude map to obtain the current location

ACM. Hj16 shopping list ●●

The software test interview has been suspended. The interviewer always says that the logical thinking is chaotic. What should I do?

史上最简单的录屏转gif小工具LICEcap,要求不高可以试试

jdbc常见异常及错误解决办法汇总
随机推荐
Megacli常用命令整理
Analysis on resource leakage /goroutine leakage / memory leakage /cpu full in go
My vscode
Screen recording to GIF is an easy-to-use gadget, screentogif, which is free and easy to use!
Summary of common JDBC exceptions and error solutions
How does excel translate Chinese words into English automatically? This formula teaches you
为什么Integer的比较最好使用equals
Online customer service - charging standards and service provision of third parties
24class static member
音频基础知识以及PCM转WAV
Analysis and comprehensive summary of full type equivalent judgment in go
录屏转gif的好用小工具ScreenToGif,免费又好用!
Ad20 learning notes I
Qtcreator formatting code
Pointer strengthening and improvement
解决‘tuple‘ object has no attribute ‘lower‘
CSDN添加页内跳转和页外指定段落跳转
解决TypeError: Unicode-objects must be encoded before hashing
分享一个OSGeo4W64下载好的库,基于qgis3.10的
Today's 61 Fu