-
Notifications
You must be signed in to change notification settings - Fork 699
br: pitr filter feature release doc #21109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tristan1900
wants to merge
4
commits into
pingcap:master
Choose a base branch
from
Tristan1900:pitr-filter-doc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -496,6 +496,82 @@ tiup br restore point --pd="${PD_IP}:2379" | |||||
--master-key "local:///path/to/master.key" | ||||||
``` | ||||||
|
||||||
### Restore with filters | ||||||
|
||||||
Starting from TiDB v9.0.0, you can use filters during PITR to selectively restore specific databases or tables. This allows for more granular control over what data gets restored during point-in-time recovery operations. | ||||||
|
||||||
The filter patterns follow the same syntax as [table filters](/table-filter.md) used in other BR operations: | ||||||
|
||||||
- `'*.*'` - matches all databases and tables | ||||||
- `'db1.*'` - matches all tables in database `db1` | ||||||
- `'db1.table1'` - matches specific table `table1` in database `db1` | ||||||
- `'db*.tbl*'` - matches databases starting with `db` and tables starting with `tbl` | ||||||
- `'!mysql.*'` - excludes all tables in the `mysql` database | ||||||
|
||||||
Usage examples: | ||||||
|
||||||
```shell | ||||||
# restore specific databases | ||||||
tiup br restore point --pd="${PD_IP}:2379" \ | ||||||
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--full-backup-storage='s3://backup-101/snapshot-20250602000000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--start-ts "2025-06-02 00:00:00+0800" \ | ||||||
--restored-ts "2025-06-03 18:00:00+0800" \ | ||||||
--filter 'db1.*' --filter 'db2.*' | ||||||
|
||||||
# restore specific tables | ||||||
tiup br restore point --pd="${PD_IP}:2379" \ | ||||||
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--full-backup-storage='s3://backup-101/snapshot-20250602000000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--start-ts "2025-06-02 00:00:00+0800" \ | ||||||
--restored-ts "2025-06-03 18:00:00+0800" \ | ||||||
--filter 'db1.users' --filter 'db1.orders' | ||||||
|
||||||
# restore with pattern matching | ||||||
tiup br restore point --pd="${PD_IP}:2379" \ | ||||||
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--full-backup-storage='s3://backup-101/snapshot-20250602000000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--start-ts "2025-06-02 00:00:00+0800" \ | ||||||
--restored-ts "2025-06-03 18:00:00+0800" \ | ||||||
--filter 'db*.tbl*' | ||||||
``` | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> - When using filters, ensure that the filtered data maintains referential integrity. | ||||||
> - Filter options apply to both snapshot and log backup restoration phases. | ||||||
> - Multiple `--filter` options can be specified to include or exclude different patterns. | ||||||
> - PITR filtering does not support system tables yet. If you need to restore specific system tables, use `br restore full` with filters instead, which will restore only the snapshot backup data (not log backup data). | ||||||
> - The target databases and tables specified in the filter must not exist in the cluster, or the restore will fail with an error. | ||||||
|
||||||
### Concurrent restore operations | ||||||
|
||||||
Starting from TiDB v9.0.0, you can run multiple PITR operations concurrently. This feature allows you to restore different datasets simultaneously, improving restore efficiency for large-scale operations. | ||||||
|
||||||
Usage example for concurrent restores: | ||||||
|
||||||
```shell | ||||||
# terminal 1 - restore database db1 | ||||||
tiup br restore point --pd="${PD_IP}:2379" \ | ||||||
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--full-backup-storage='s3://backup-101/snapshot-20250602000000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--start-ts "2025-06-02 00:00:00+0800" \ | ||||||
--restored-ts "2025-06-03 18:00:00+0800" \ | ||||||
--filter 'db1.*' | ||||||
|
||||||
# terminal 2 - restore database db2 (can run simultaneously) | ||||||
tiup br restore point --pd="${PD_IP}:2379" \ | ||||||
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--full-backup-storage='s3://backup-101/snapshot-20250602000000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}' \ | ||||||
--start-ts "2025-06-02 00:00:00+0800" \ | ||||||
--restored-ts "2025-06-03 18:00:00+0800" \ | ||||||
--filter 'db2.*' | ||||||
``` | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> - Each concurrent restore operation must target different databases or non-overlapping table sets. Attempting to restore overlapping datasets concurrently will result in an error. | ||||||
|
||||||
### Compatibility between ongoing log backup and snapshot restore | ||||||
|
||||||
Starting from v9.0.0, when a log backup task is running, if all of the following conditions are met, you can still perform snapshot restore (`br restore [full|database|table]`) and allow the restored data to be properly recorded by the ongoing log backup (hereinafter referred to as "log backup"): | ||||||
|
@@ -507,13 +583,26 @@ Starting from v9.0.0, when a log backup task is running, if all of the following | |||||
- The data to be restored uses the same type of external storage as the target storage for the log backup. | ||||||
- Neither the data to be restored nor the log backup has enabled local encryption. For details, see [log backup encryption](#encrypt-the-log-backup-data) and [snapshot backup encryption](/br/br-snapshot-manual.md#encrypt-the-backup-data). | ||||||
|
||||||
If any of the above conditions are not met, or if you need to perform a point-in-time recovery, while a log backup task is running, BR refuses to proceed with the data recovery. In this case, you can complete the recovery by following these steps: | ||||||
|
||||||
If any of the above conditions are not met, you can complete the recovery by following these steps: | ||||||
1. [Stop the log backup task](#stop-a-log-backup-task). | ||||||
2. Perform the data restore. | ||||||
3. After the restore is complete, perform a new snapshot backup. | ||||||
4. [Restart the log backup task](#restart-a-log-backup-task). | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> When restoring a log backup that contains records of snapshot (full) restore data, you must use BR v9.0.0 or later. Otherwise, restoring the recorded full restore data might fail. | ||||||
> When restoring a log backup that contains records of snapshot (full) restore data, you must use BR v9.0.0 or later. Otherwise, restoring the recorded full restore data might fail. | ||||||
|
||||||
### Compatibility between ongoing log backup and PITR operations | ||||||
|
||||||
Starting from TiDB v9.0.0, you can perform PITR operations while a log backup task is running by default. The system automatically handles compatibility between these operations. | ||||||
|
||||||
#### Important limitation for PITR with ongoing log backup | ||||||
|
||||||
When performing PITR operations while log backup is running, the restored data will be recorded in the log backup. However, during the restore time window, the data may not be consistent due to the nature of log restore operations. The system writes metadata to external storage to mark both the time range and data range where consistency cannot be guaranteed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To maintain consistency with the style guide's recommendation to use the second person ('you') 1, could the beginning of this sentence be rephrased? Style Guide References
Suggested change
Footnotes |
||||||
|
||||||
If such inconsistency occurs during the time range `[t1, t2)`, you cannot restore data from that time period. Instead, you must: | ||||||
|
||||||
- Restore data up to `t1` (before the inconsistent period), or | ||||||
- Take a new snapshot backup after `t2` and use that for future PITR operations | ||||||
- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To align with the style guide's preference for addressing users in the second person 1, consider rephrasing this sentence.
Style Guide References
Footnotes
The style guide recommends writing in the second person ('you') when addressing users. (link) ↩