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"
相关推荐
倔强的石头_42 分钟前
kingbase备份与恢复实战(六)—— 备份自动化与保留策略:Windows任务计划+日志追溯
数据库
轻刀快马2 小时前
别被 ORM 框架宠坏了:从一场“订单消失”悬案,看懂 MySQL 为什么要强推 InnoDB
数据库·mysql
后端漫漫3 小时前
Redis 客户端工具体系
数据库·redis·缓存
PaperData4 小时前
1988-2025年《中国人口和就业统计年鉴》全年份excel+PDF
数据库·人工智能·数据分析·经管
星河耀银海5 小时前
C语言与数据库交互:SQLite实战与数据持久化
c语言·数据库·sqlite·交互
过期动态5 小时前
MySQL中的约束
android·java·数据库·spring boot·mysql
程序员陆通5 小时前
月烧 400 刀到不到 20 刀:我是怎么把 OpenClaw 的 Token 账单砍掉 95% 的
java·前端·数据库
Shan12055 小时前
站在计算机领域视角看:SQL注入攻击
网络·数据库·sql
轻刀快马5 小时前
别干背八股文了:从一场“双十一秒杀”惨案,看懂 InnoDB 事务、锁与索引的底层齿轮
数据库·sql
万事大吉CC5 小时前
【1】Django 基础:MTV 架构与核心组件
数据库·架构·django