TIDB的备份与恢复、上传OSS

一、备份

备份并上传到oss(注意br的版本要对应集群版本)

自行按需更改阿里云的信息access-key、secret-access-key、region、endpoint

1、整库备份

复制代码
tiup br:v7.5.0  backup full \
--pd "172.16.22.1:32579,172.16.22.2:32579,172.16.22.3:32579" \
--storage "s3://alltidb-backup/test/test_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com"

2、单表备份

复制代码
tiup br:v7.5.1  backup table \
--pd "172.16.22.1:32579,172.16.22.2:32579,172.16.22.3:32579" \
--db "test" \
--table "test_table" \
--storage "s3://alltidb-backup/test/test-test_table_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com"

二、查看

查看某个快照备份对应的快照物理时间点

复制代码
tiup br:v7.5.0 validate decode --field="end-version" \
--storage "s3://alltidb-backup/test/test_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com" | tail -n1

三、恢复

1、恢复单个数据库的数据

复制代码
tiup br:v7.5.0 restore db \
--pd "172.16.22.1:32579,172.16.22.2:32579,172.16.22.3:32579" \
--db "test" \
--storage "s3://alltidb-backup/test/test_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com"

2、恢复单张表的数据

复制代码
tiup br:v7.5.0 restore table \
--pd "172.16.22.1:32579,172.16.22.2:32579,172.16.22.3:32579" \
--db "test" \
--table "test_table" \
--storage "s3://alltidb-backup/test/test-test_table_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com"

3、使用表库过滤功能恢复部分数据

复制代码
tiup br:v7.5.0 restore full \
--pd "172.16.22.1:32579,172.16.22.2:32579,172.16.22.3:32579" \
--filter 'db*.tbl*' \
--storage "s3://alltidb-backup/test/test_20241217?access-key=xxxxxxxx&secret-access-key=xxxxxxxx" \
--s3.provider "alibaba" \
--s3.region "oss-ap-southeast-1" \
--s3.endpoint "https://oss-ap-southeast-1-internal.aliyuncs.com"
相关推荐
李广坤6 小时前
MySQL 大表字段变更实践(改名 + 改类型 + 改长度)
数据库
爱可生开源社区1 天前
2026 年,优秀的 DBA 需要具备哪些素质?
数据库·人工智能·dba
随逸1771 天前
《从零搭建NestJS项目》
数据库·typescript
加号32 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
シ風箏2 天前
MySQL【部署 04】Docker部署 MySQL8.0.32 版本(网盘镜像及启动命令分享)
数据库·mysql·docker
李慕婉学姐2 天前
Springboot智慧社区系统设计与开发6n99s526(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
百锦再2 天前
Django实现接口token检测的实现方案
数据库·python·django·sqlite·flask·fastapi·pip
tryCbest2 天前
数据库SQL学习
数据库·sql
jnrjian2 天前
ORA-01017 查找机器名 用户名 以及library cache lock 参数含义
数据库·oracle
十月南城2 天前
数据湖技术对比——Iceberg、Hudi、Delta的表格格式与维护策略
大数据·数据库·数据仓库·hive·hadoop·spark