How to recover data after accidental deletion? The time point is before tikv_gc_safe_point

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

Original topic: 误删数据后怎么恢复?时间点在tikv_gc_safe_point之前

| username: Hacker_qeCXjAN2

【TiDB Usage Environment】Production\Test Environment\POC
【TiDB Version】V5.0.0
【Encountered Problem】Accidentally deleted some data and want to restore to the point before the deletion. The deletion time is before tikv_gc_safe_point. Thank you!
【Reproduction Path】What operations were performed that caused the problem
【Problem Phenomenon and Impact】

| username: Hacker_qeCXjAN2 | Original post link

Is there any way to recover the data before the GC time point?

| username: 大鱼海棠 | Original post link

If you have a backup, you can restore it. If not, it cannot be restored.

| username: 啦啦啦啦啦 | Original post link

It is not possible to restore based on historical version information. It is recommended to use database backups for recovery.

| username: 近墨者zyl | Original post link

You can try and see if it can be undetected. If there are binary logs, it can be restored.

| username: Hacker_qeCXjAN2 | Original post link

There is synchronization to the downstream through pump+drainer, but in this way, the downstream also executes delete, right? Is it impossible to recover?

| username: wuxiangdong | Original post link

First, check if there is a GC. If not, you can only restore the entire database and then import the deleted data.

| username: Hacker_qeCXjAN2 | Original post link

How can I operate it?

| username: 大鱼海棠 | Original post link

Drainer can output to a downstream file format. If you have a full backup and binlog within a specific time range, you can restore it.

| username: Hacker_qeCXjAN2 | Original post link

Our drainer is currently syncing to the downstream TiDB. How can we proceed? Thank you!

| username: buddyyuan | Original post link

If you haven’t modified the GC time of your pump, it should be 7 days by default. You can restart a drainer component and set it to file. Then, set the TSO for the drainer startup to a point before the deletion time, and it should work.

| username: Hacker_qeCXjAN2 | Original post link

Pump is 7 days, I’ll give it a try, thank you!

| username: 近墨者zyl | Original post link

Has it been restored?