Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb-lighting恢复数据
[TiDB Usage Environment] Production Environment / Test / Poc
Production
[TiDB Version]
5.2.1
[Reproduction Path] What operations were performed to cause the issue
[Encountered Issue: Issue Phenomenon and Impact]
After using dumpling to back up data, I used lighting to restore the data, but I want to restore it to a specified schema. How should I write this in the configuration file?
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]
The data exported by dumpling is named using database_name.table_name
. You can try changing the database_name
to the schema name you want to import into, and then use Lightning to import it.
The database and table names in the data file and schema file need to be changed; just changing the file name is not enough.
The 5.2 version of Lightning supports route rules, you can check it out:
# Set the sharding merge rules to import table1 and table2 from my_db1, and table3 and table4 from my_db2, a total of 4 tables from 2 databases, into table5 in the target database my_db.
# [[routes]]
# schema-pattern = "my_db1"
# table-pattern = "table[1-2]"
# target-schema = "my_db"
# target-table = "table5"
#
# [[routes]]
# schema-pattern = "my_db2"
# table-pattern = "table[3-4]"
# target-schema = "my_db"
# target-table = "table5"
FYI: TiDB Lightning 配置参数 | PingCAP 文档中心
I remember that the data file does not contain schema information. Of course, it would be better to solve the problem with configuration.
I changed the database name and encountered a check error. I see that the tables in the database have been created, but the data hasn’t been inserted. It reported a check error.
Are your data path and temporary path on the same physical disk?
Yes, it cannot be placed on a single disk?
Sure, when using Lightning, add the parameter --check-requirements=false to skip the disk check.
If you use dumpling to export the SQL file, it will contain the database and table names.
The precheck error reported by lightning will be printed to stdout. You can check which item did not pass:
Got it, I saw the output log reporting an error, but the lingting log didn’t report an error, so I thought it was wrong. Then I checked and the data had already come through. Thanks for the explanation.
After completion, you need to check the data. The error message in your screenshot only indicates that your two paths are on the same disk, which may affect performance, but it’s not a big issue.
Can this route rule be used in all backend modes?
Yes, both tidb-backend and local-backend are fine.