Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb br日志增量备份恢复问题
[TiDB Usage Environment] Production Environment
[TiDB Version] v7.1.1
[Reproduction Path] Unable to restore data from 30 minutes ago
[Encountered Problem: Problem Phenomenon and Impact] After a full BR backup, log incremental backup was enabled. Now, it is impossible to restore data from half an hour ago. Error reported: Error: it has gap between full backup ts:448487459931815937(2024-03-19 18:24:47.069 +0800 CST) and log backup ts:448487473956519937(2024-03-19 18:25:40.569 +0800 CST). :[BR:Common:ErrInvalidArgument]invalid argument
Error
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]
Is it only possible to restore to the point in time before the full backup, but not after the full backup?
First enable logging, then perform a full database backup. You can do the full database backup afterwards.
Yesterday, I did a full backup. Then I enabled logging, and today I prepared to test the restore but it didn’t work.
tiup br restore point --pd "pd-01:30001" \
--storage="s3://tidb-test-backup/br/logbackup? \
--full-backup-storage="s3://tidb-test-backup/br/snapshot-202403191824 \
--restored-ts '2024-03-20 11:58:00+0800'
Is there a gap between the ts specified for your log backup and the ts during the full backup? It’s best to specify the ts at the completion of the full backup for the log backup, or start the log backup first and then proceed with the full backup.
Thank you, master. The log backup did not specify ts.
I did a full backup first and then started the log backup.
So you got the order wrong. First, enable logging, then back up the entire database. You lost the logs for the part after the full database.
Thank you, boss. So how should I schedule regular backups in the future? A full backup once a day, and should I keep the log backup running?
Once you enable log backup, don’t turn it off. For full and incremental backups, you need to write a scheduled task.
Is it necessary to turn off log backups during recovery?
Once log backup is enabled, it will continue to back up. Then you perform full backups periodically. After the full backup is completed, the previous full backup and log backups can be deleted.
Got it, boss. One more question: Can BR log backup and restore only be done in a new environment? I just tested it and found that it can only be restored in a cluster that doesn’t already exist.
Log backups must be restored based on a full backup. For example, if you start continuous log backups from the 1st, perform a full backup on the 3rd, 5th, and 7th, and then want to restore data to the 6th, you need to first restore the full backup from the 5th and then specify the log backup to restore to the 6th.
I tested the recovery, and it prompted that the database cannot have the same name to execute. Does this mean that the log recovery can only be done in a new environment?
Need to clear data or restore to a new environment.
Before performing PITR, check the full backup point and log point.
Full backup point:
br validate decode --field="end-version" --storage "local:///backup/full" | tail -n1
Log backup point:
br log metadata --storage 'local:///backup/log/'
The logs between the full backup point and the point to be restored need to be continuous.