加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xtrabackup-整库,单表,部分备份恢复

发布时间:2020-12-14 05:39:30 所属栏目:百科 来源:网络整理
导读:创建部分备份(Creating Partial Backups) 部分备份共有三种方式,分别是: 1. 用正则表达式表示要备份的库名及表名(参数为--include) 2. 将要备份的表名或库名都写在一个文本文件中(参数为--tables-file) 3. 将要备份表名或库名完整的写在命令行中(参
创建部分备份(Creating Partial Backups)
部分备份共有三种方式,分别是:
1. 用正则表达式表示要备份的库名及表名(参数为--include)
2. 将要备份的表名或库名都写在一个文本文件中(参数为--tables-file)
3. 将要备份表名或库名完整的写在命令行中(参数为:--databases)。
(译者注:不管你备份哪个库或是哪张表,强烈推荐把mysql库也一起备份,恢复的时候要用。)

方式一:使用--include参数
使用正则模式匹配备份部分库表,需要使用参数--include
innobackupex --include=‘test.test*‘ /backup --user=root --password=msds007
?
方式二:使用表列表备份部分表,需要使用参数--tables-file,语句类似如下:
cat /tmp/tables.txt
test.t
test.testflashback2
innobackupex --tables-file=/tmp/tables.txt /backup --user=root --password=msds007
?
方式三:使用--databases参数
innobackupex --databases=test,mysql /backup --user=root --password=msds007
?
准备部分备份(Preparing Partial Backups)
执行preparing partial backups,与恢复独立的表(Restoring Individual Tables)很类似:使用--apply-log和--export参数,并包含上一步生成的时间戳文件夹
innobackupex --apply-log --export /backup/2018-05-10_19-38-44
?
恢复部分备份(Restoring Partial Backups)
1)查看备份集中的文件
[ [email?protected] test]# pwd
/backup/2018-05-10_19-38-44/test
[ [email?protected] test]# ll
total 256
-rw-r--r--. 1 root root?? 390 May 10 19:58 t.cfg
-rw-r--r--. 1 root root? 1087 May 10 19:58 testflashback2.cfg
-rw-r--r--. 1 root root 16384 May 10 19:58 testflashback2.exp
-rw-r-----. 1 root root? 9030 May 10 19:38 testflashback2.frm
-rw-r-----. 1 root root 98304 May 10 19:38 testflashback2.ibd
-rw-r--r--. 1 root root 16384 May 10 19:58 t.exp
-rw-r-----. 1 root root? 8586 May 10 19:38 t.frm
-rw-r-----. 1 root root 98304 May 10 19:38 t.ibd
?
2)建表,可以从frm文件中解析出建表语句
# mysqlfrm --diagnostic t.frm
# WARNING: Cannot generate character set or collation names without the --server option.
# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such,it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
# Reading .frm file for t.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
[ [email?protected] ~]# mysqlfrm --server=dba_user: [email?protected] /app/mysqldata/3306/data/test/tt.frm --user=root --port=2323
--server=dba_user: [email?protected]???? 远端服务器,要读取的数据字典
/app/mysqldata/3306/data/test/tt.frm????????????? frm源文件放置的本地位置
--user=root --port=2323????????????????????????????????????? Starting the spawned server on port 2323
CREATE TABLE `t` (
? `id` int(11) NOT NULL AUTO_INCREMENT,
? `name` varchar(20) DEFAULT NULL,
PRIMARY KEY `PRIMARY` (`id`)
) ENGINE=InnoDB;
#...done.
?
3)导入数据 ALTER TABLE test.t DISCARD TABLESPACE; After this,copy t.ibd and t.exp ( or t.cfg if importing to MySQL 5.6) files to database’s home,and import its tablespace: chown mysql:mysql t.ibd t.exp t.cfg ALTER TABLE test.t IMPORT TABLESPACE;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读