当前位置:网站首页>Br backup test
Br backup test
2022-06-13 06:50:00 【Lao Wang's notes】
Full backup recovery
Full volume backup
1, Create a backup directory
stay BR Nodes and each TiKV Node create folder , Used to store backup files , Make sure the folder is empty ;
mkdir -p /export/servers/TiDB/backup
chmod 777 /export/servers/TiDB/backupbin ]# br backup full --pd "X.X.X.X:2379" --storage "/export/servers/TiDB/backup" --ratelimit 120 --log-file backfull.log
Detail BR log in backfull.log
Full backup <------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 14:59:30.672 +08:00] [INFO] [collector.go:62] ["Full backup success summary"] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-checksum=1.482612ms] [backup-fast-checksum=1.935795ms] [backup-total-regions=1] [BackupTS=431112262921748484] [Size=3596] [total-take=96.37658ms] [total-kv=4] [data-size=144B] [average-speed=3.183kB/s]The returned information shows the progress of the backup ; After the backup, it will be done automatically checksum check ;
2, View backup files
X.X.X.X | SUCCESS | rc=0 >>
backup.lock
backupmeta
X.X.X.X | SUCCESS | rc=0 >>
X.X.X.X | SUCCESS | rc=0 >>
5_44_37_9fb8afb3f7322e93f506f0d9d11e9b1569bc90b7c3779da9bb7e35137e8e6597_1644562770644_write.sst
X.X.X.X| SUCCESS | rc=0 >>KV There will be... Under the backup directory of the node SST file ; BR There will be one under the node backupmeta Metadata files and backup.lock file , Prompt other jobs The task is backing up ;
Full recovery
1, Delete first test Kuhe tony library
mysql> drop database test;
droQuery OK, 0 rows affected (0.43 sec)
mysql> drop database tony;
Query OK, 0 rows affected (0.60 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| INFORMATION_SCHEMA |
| METRICS_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql |
+--------------------+
4 rows in set (0.00 sec)2, COPY Backup set , Ensure that all TiKV Node storage All folders have a full amount of SST file ;

3, Perform recovery
backup]# br restore full --pd "X.X.X.X:2379" --storage "local:///export/servers/TiDB/backup" --ratelimit 120 --log-file restorefull.log
Detail BR log in restorefull.log
Full restore <-----------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 15:54:13.815 +08:00] [INFO] [collector.go:62] ["Full restore success summary"] [total-ranges=2] [ranges-succeed=2] [ranges-failed=0] [split-region=154.023832ms] [restore-checksum=4.128595ms] [restore-ranges=1] [Size=3596] [total-take=2.784340011s] [total-kv=4] [data-size=144B] [average-speed=1.454kB/s]4, data validation
mysql> select * from tony.hero;
+----+-----------+
| id | name |
+----+-----------+
| 1 | zhangliao |
| 2 | zhaoyun |
| 3 | pangtong |
| 4 | zhangsan |
+----+-----------+
4 rows in set (0.01 sec)Single library level backup and recovery
Single database backup
backup]# br backup db --db tony --pd "${PD-IP}:2379" -s "/export/servers/TiDB/backup/db/" --ratelimit 120 --log-file "backupdb.log"
Detail BR log in backupdb.log
Database backup <--------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:04:59.619 +08:00] [INFO] [collector.go:62] ["Database backup success summary"] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-checksum=201.97194ms] [backup-fast-checksum=382.261µs] [backup-total-regions=1] [Size=608884] [BackupTS=431113292728238082] [total-take=660.785589ms] [data-size=9.437MB] [average-speed=22.88MB/s] [total-kv=262144]Be careful : If you make a mistake :Error: backup lock exists, may be some backup files in the path already: [BR:Common:ErrInvalidArgument]invalid argument
There may be other tasks being performed , If it is confirmed that there is no , Delete BR Node under backup.lock Then retry the backup ;
Single database recovery
1, Delete data
mysql> select count(1) from tony.hero;
+----------+
| count(1) |
+----------+
| 262144 |
+----------+
1 row in set (0.01 sec)
mysql> drop database tony;
Query OK, 0 rows affected (0.52 sec)
2, Will back up files COPY, Ensure that all TiKV All nodes have full data
3, recovery
br restore db --db tony --pd "${PD_IP}:2379" -s "/export/servers/TiDB/backup/db/" --ratelimit 120 --log-file "restoredb.log" Detail BR log in restoredb.log
Database restore <-------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:13:41.561 +08:00] [INFO] [collector.go:62] ["Database restore success summary"] [total-ranges=2] [ranges-succeed=2] [ranges-failed=0] [split-region=1.160223ms] [restore-checksum=193.264465ms] [restore-ranges=1] [Size=608884] [total-take=2.402358075s] [total-kv=262144] [data-size=9.437MB] [average-speed=9.032MB/s]Single table backup restore
1, Backup
backup]# br backup table --db tony -t hero --pd "${PD_IP}:2379" -s "/export/servers/TiDB/backup/tb" --ratelimit 120 --log-file "backuptb.log"
Detail BR log in backuptb.log
Table backup <-----------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:19:31.200 +08:00] [INFO] [collector.go:62] ["Table backup success summary"] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-checksum=184.963549ms] [backup-fast-checksum=370.343µs] [backup-total-regions=1] [BackupTS=431113521134305281] [Size=608888] [total-take=966.424733ms] [data-size=9.437MB] [average-speed=12.96MB/s] [total-kv=262144]2, Clean up table data , Synchronization TiKV Backup file ;

3, Resume
br restore table --db tony -t hero --pd "${PD-IP}:2379" -s "/export/servers/TiDB/backup/tb" --ratelimit 120 --log-file "restoretb.log"
Detail BR log in restoretb.log
Table restore <----------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:24:11.573 +08:00] [INFO] [collector.go:62] ["Table restore success summary"] [total-ranges=2] [ranges-succeed=2] [ranges-failed=0] [split-region=378.427981ms] [restore-checksum=193.732455ms] [restore-ranges=1] [Size=608888] [total-take=3.37811245s] [total-kv=262144] [data-size=9.437MB] [average-speed=8.395MB/s]4, verification
mysql> select count(1) from hero;
+----------+
| count(1) |
+----------+
| 262144 |
+----------+
1 row in set (0.18 sec)Incremental backup recovery
First, perform a full backup
br backup full --pd "${PD-IP}:2379" -s "/export/servers/TiDB/backup/all" --ratelimit 120 --log-file "backupfull.log"
Detail BR log in backupfull.log
Full backup <------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:28:37.012 +08:00] [INFO] [collector.go:62] ["Full backup success summary"] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-checksum=171.02832ms] [backup-fast-checksum=373.579µs] [backup-total-regions=1] [BackupTS=431113664291143682] [Size=608878] [total-take=646.427791ms] [total-kv=262144] [data-size=9.437MB] [average-speed=22.05MB/s]Analog data writing :
mysql> show tables;
+----------------+
| Tables_in_tony |
+----------------+
| hero |
+----------------+
1 row in set (0.00 sec)
mysql> create table hero2 like hero;
Query OK, 0 rows affected (0.19 sec)
mysql> insert into hero2 select * from hero limit 10;
Query OK, 10 rows affected (0.11 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> delete from hero where id = 1;
Query OK, 1 row affected (0.03 sec)
mysql> Get the timestamp of the last backup
backup]# br validate decode --field="end-version" -s "/export/servers/TiDB/backup/all" | tail -n1
Detail BR log in /tmp/br.log.2022-02-11T16.30.53+0800
431113664291143682Create a new incremental backup directory , And perform incremental backup
backup]# br backup full --pd "XX.XX.XX.XX:2379" -s "/export/servers/TiDB/backup/incr1" --lastbackupts 431113664291143682
Detail BR log in /tmp/br.log.2022-02-11T16.36.14+0800
Full backup <------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:36:14.937 +08:00] [INFO] [collector.go:62] ["Full backup success summary"] [total-ranges=2] [ranges-succeed=2] [ranges-failed=0] [backup-checksum=82.305µs] [backup-total-regions=2] [BackupTS=431113784471322626] [Size=8592] [total-take=108.682153ms] [data-size=379B] [average-speed=10.77kB/s] [total-kv=11]The analog data is deleted by mistake
mysql> drop database tony;
sQuery OK, 0 rows affected (0.39 sec)
Sync first TiKV Node files and full recovery ,
br restore full --pd "XX.XX.XX.XX:2379" -s "/export/servers/TiDB/backup/all" --ratelimit 120 --log-file "restorefull.log"
Detail BR log in restorefull.log
Full restore <-----------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:51:45.716 +08:00] [INFO] [collector.go:62] ["Full restore success summary"] [total-ranges=2] [ranges-succeed=2] [ranges-failed=0] [split-region=360.522704ms] [restore-checksum=185.927304ms] [restore-ranges=1] [Size=608878] [total-take=3.843520428s] [total-kv=262144] [data-size=9.437MB] [average-speed=8.414MB/s]You can see at this time hero The table has been successfully restored ;
mysql> show tables from tony;
+----------------+
| Tables_in_tony |
+----------------+
| hero |
+----------------+
1 row in set (0.00 sec)Sync tikv Incremental files , Ensure that all nodes have full incremental backups ;
Incremental recovery ;
br restore full --pd "XX.XX.XX.XX:2379" -s "/export/servers/TiDB/backup/incr1" --ratelimit 120 --log-file "IncrRestoreFull.log"
Detail BR log in IncrRestoreFull.log
Full restore <-----------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2022/02/11 16:54:05.825 +08:00] [INFO] [collector.go:62] ["Full restore success summary"] [total-ranges=4] [ranges-succeed=4] [ranges-failed=0] [split-region=174.564434ms] [restore-checksum=251.705µs] [restore-ranges=2] [Size=8592] [total-take=2.249619054s] [total-kv=11] [data-size=379B] [average-speed=1.449kB/s]mysql> show tables;
+----------------+
| Tables_in_tony |
+----------------+
| hero |
| hero2 |
+----------------+
2 rows in set (0.00 sec)
mysql> select count(1) from hero2;
+----------+
| count(1) |
+----------+
| 10 |
+----------+
1 row in set (0.00 sec)You can see hero2 The table has also been restored successfully ;
mysql> select count(1) from hero;
+----------+
| count(1) |
+----------+
| 262143 |
+----------+
1 row in set (0.00 sec)
mysql> select * from hero where id = 1;
Empty set (0.01 sec)
and hero1 Some data deleted in (id=1) Has also been deleted ;
边栏推荐
- Kotlin data flow - flow
- [Collection des questions d'examen les plus complètes de Tencent Ali] (quatre côtés: 3 tours de technologie + 1 tour de RH)
- Notes on wechat applet development
- Scrcpy source code walk 2 how to connect a client to a mobile server
- 树莓派高级开发——“IO口驱动代码的编写“ 包含总线地址、物理_虚拟地址、BCM2835芯片手册知识
- Ijkplayer code walk through H264 unpacker application details
- Upper computer development (software test of firmware download software)
- 同花顺可以开股票账户吗?安全吗?
- Jinglianwen Technology: current situation and solutions of data acquisition and labeling industry
- Error in downloading opencv from pip
猜你喜欢

Differences between SQL and NoSQL of mongodb series

【马尔科夫链-蒙特卡罗】马尔科夫链-蒙特卡罗方法对先验分布进行抽样

【sketchup 2021】草图大师的图像输出与渲染之样式说明【边线设置、平面设置、背景设置、水印设置、建模设置、天空背景创建天空、利用水印背景创建天空(重要)】

AIO Introduction (VIII)

学习Mysql基础第一天

YOLOv5解析 | 参数与性能指标

15、 IO stream (I)

The innovative public platoon mode team invites users to split, beautiful every second, and links the 2+1 new business model

景联文科技提供语音数据采集标注服务

Do you want to carry out rapid steel mesh design and ensure the quality of steel mesh? Look here
随机推荐
How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
基于FPGA的ds18b20温度传感器使用
Unable to locate program input point getrawinputdevicelist in dynamic link library user32 DLL processing
髋关节MR详细图谱(转载)
十五、IO流(一)
【腾讯阿里最全面试题集锦】(四面:3轮技术+1轮HR)
牙周炎问题调研(持续进行中)
Network planning common interview knowledge (I)
杭州网上开户是安全的吗?
Use of smalidea
Computer network interview questions
Cocos creator obtains user authorization interface and encapsulates createuserinfobutton
机器学习笔记 - 监督学习备忘清单
Will the chain 2+1 model be a new business outlet and a popular Internet e-commerce market?
【云原生 | Kubernetes篇】Kubernetes 配置
How to seize the bonus of social e-commerce through brand play to achieve growth and profit?
Detailed explanation of the player network data reading process of ijkplayer code walkthrough 2
Subtotal of constraintlayout
16、 IO stream (II)
JNI exception handling