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"