How to Backup and Restore a Database When Starting a Cluster Using Playground v7.2.0, Please Provide Guidance

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用 playground v7.2.0 启动集群,如何备份和恢复数据库,指点一下

| username: TiDBer_4ZtoEU7K

[TiDB Usage Environment] Development Environment
[TiDB Version] v7.2.0
I just want to ask, how to backup and restore the database in TiDB v7.2.0? I read the documentation and got confused.

| username: ShawnYan | Original post link

If it’s a playground, you can directly package the ~/.tiup/data/ folder.

| username: tidb菜鸟一只 | Original post link

br or dumpling+lighting

| username: 我是咖啡哥 | Original post link

Here, I’ll give you the simplest example.
Use BACKUP DATABASE to back up the database and RESTORE database to restore the database: take the test database as an example.


root@127.0.0.1:4000[(none)]>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@127.0.0.1:4000[test]>show tables;
+----------------+
| Tables_in_test |
+----------------+
| my_table       |
+----------------+
1 row in set (0.00 sec)

root@127.0.0.1:4000[test]>select * from my_table;
+---------------------+---------+----------+
| id                  | name    | code     |
+---------------------+---------+----------+
|  576460752303423492 | test2   | website2 |
| 4611686018427387905 | test    | website  |
+---------------------+---------+----------+
2 rows in set (0.00 sec)

root@127.0.0.1:4000[test]>BACKUP DATABASE `test` TO '/tmp';
+-------------+------+--------------------+---------------------+---------------------+
| Destination | Size | BackupTS           | Queue Time          | Execution Time      |
+-------------+------+--------------------+---------------------+---------------------+
| /tmp        | 5492 | 442997127910785026 | 2023-07-21 08:38:52 | 2023-07-21 08:38:52 |
+-------------+------+--------------------+---------------------+---------------------+
1 row in set (0.20 sec)

root@127.0.0.1:4000[test]>show backups;
+------+-------------+----------+----------+---------------------+---------------------+---------------------+---------------------+---------+
| Id   | Destination | State    | Progress | Queue_time          | Execution_time      | Finish_time         | Connection          | Message |
+------+-------------+----------+----------+---------------------+---------------------+---------------------+---------------------+---------+
|    1 | /tmp        | Checksum |      100 | 2023-07-21 08:38:52 | 2023-07-21 08:38:52 | 2023-07-21 08:38:52 | 7843034144228507657 | NULL    |
+------+-------------+----------+----------+---------------------+---------------------+---------------------+---------------------+---------+
1 row in set (0.00 sec)

root@127.0.0.1:4000[test]>drop database test;
Query OK, 0 rows affected (0.33 sec)

root@127.0.0.1:4000[test]>RESTORE database `test` FROM '/tmp';
+-------------+------+--------------------+--------------------+---------------------+---------------------+
| Destination | Size | BackupTS           | Cluster TS         | Queue Time          | Execution Time      |
+-------------+------+--------------------+--------------------+---------------------+---------------------+
| /tmp        | 5492 | 442997127910785026 | 442997151373459460 | 2023-07-21 08:40:22 | 2023-07-21 08:40:22 |
+-------------+------+--------------------+--------------------+---------------------+---------------------+
1 row in set (0.87 sec)
Rows matched: 0  Changed: 0  Warnings: 0

root@127.0.0.1:4000[test]>show tables;
ERROR 1046 (3D000): No database selected
root@127.0.0.1:4000[test]>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@127.0.0.1:4000[test]>show tables;
+----------------+
| Tables_in_test |
+----------------+
| my_table       |
+----------------+
1 row in set (0.00 sec)

root@127.0.0.1:4000[test]>select * from my_table;
+---------------------+---------+----------+
| id                  | name    | code     |
+---------------------+---------+----------+
|  576460752303423492 | test2   | website2 |
| 4611686018427387905 | test    | website  |
+---------------------+---------+----------+
2 rows in set (0.00 sec)

| username: redgame | Original post link

Check the usage of dumpling.

| username: zhanggame1 | Original post link

Got it, for small data volumes, any commonly used backup tool can be used.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.