Skip to content

br: document restore with --rename - #21936

Open
LykxSassinator wants to merge 2 commits into
pingcap:masterfrom
LykxSassinator:br/restore_with_rename
Open

LykxSassinator wants to merge 2 commits into
pingcap:masterfrom
LykxSassinator:br/restore_with_rename

Conversation

@LykxSassinator

@LykxSassinator LykxSassinator commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

First-time contributors' checklist

What is changed, added, or deleted? (Required)

Document the experimental --rename flag of BR restore, which restores backup data
into a different schema or table (pingcap/tidb#70590).

Changes by file:

  • br/br-snapshot-manual.md (+59 −1)
    • Add a new section 恢复到不同的库表名: rule syntax (源库名:目标库名 /
      源库名.源表名:目标库名.目标表名), table-rule precedence over schema rules,
      case-insensitive matching, pre-restore validation of duplicate/conflicting rules,
      a br restore full example, and the limitations.
    • Add the section to the page's navigation list.
    • Update the outdated note in 恢复单个数据库的数据 that said data can only be
      restored into a database with the same name.
  • br/br-pitr-manual.md (+34)
    • Add the same-named section for PITR, plus the --rename line to the
      br restore point --help sample.
    • Document that the rules are recorded in the restore checkpoint and the PITR ID Map,
      so a later restore (including log-only restore) must use the same rules, otherwise
      the restore fails with restore rename rules do not match the log restore checkpoint.
  • br/use-br-command-line-tool.md (+2)
    • Add --rename to 常用选项 and to the restore command index.
  • br/br-snapshot-guide.md (+22) / br/br-pitr-guide.md (+2)
    • Add usage-guidance entries with schema-level and table-level examples.
  • br/backup-and-restore-overview.md / br/br-incremental-guide.md (+1 each)
    • Add the new flag to the usage-limitation lists: incremental snapshot restore is not
      supported, and neither are restore raw / restore txn.

The flag is available from TiDB v9.0.0. Because of the possible hidden risk, the feature is
marked as an experimental feature at every entry point
, using the repository's standard
warning block (该功能为实验特性,不建议在生产环境中使用。该功能可能会在未事先通知的情况下发生变化或删除。…).

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

  • Related code change PR links (if applicable):
  • This PR is translated from:
  • Other reference link(s):

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • 文档
    • 新增使用 --rename 将快照恢复和 PITR 数据映射到不同库表名的说明及示例。
    • 补充库级、表级映射规则、优先级、冲突校验及多步恢复限制。
    • 明确目标库表不得已有数据,且该功能为实验特性,不建议在生产环境使用。
    • 说明增量备份、restore rawrestore txn--no-schema 不支持 --rename

Document the experimental `--rename` flag of BR restore, which restores
backup data into a different schema or table:

- Add a "恢复到不同的库表名" section to the snapshot and PITR command manuals,
  covering rule syntax, table-rule precedence over schema rules,
  case-insensitive matching, pre-restore validation of duplicate/conflicting
  rules, supported commands, and limitations.
- Document that the rename rules are recorded in the restore checkpoint and
  the PITR ID Map, so a later restore (including log-only restore) must use
  the same rules.
- Update the outdated note that data can only be restored into a database
  with the same name when using `br restore db`.
- Mention the flag in the br command-line manual, the snapshot/PITR usage
  guides, the overview usage limitations, and the incremental backup
  limitations.

The flag is available from TiDB v9.0.0 and is marked as an experimental
feature at every entry point.

Related code PR: pingcap/tidb#70590

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jackysp for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Sep 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

Hi @LykxSassinator. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 16, 2026
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

文档新增 BR 恢复的 --rename 说明,覆盖快照恢复和 PITR 的映射格式、示例、校验规则、实验状态及不支持的恢复路径。

Changes

BR 恢复库表重命名

Layer / File(s) Summary
参数说明与适用范围
br/use-br-command-line-tool.md, br/backup-and-restore-overview.md, br/br-incremental-guide.md
新增 --rename 的映射格式、优先级、实验状态和限制。增量恢复、restore rawrestore txn 不支持该参数。
快照恢复重命名
br/br-snapshot-manual.md, br/br-snapshot-guide.md
新增库级和表级映射规则、恢复示例、冲突校验、目标库表限制及与 --no-schema 的互斥限制。
PITR 重命名恢复
br/br-pitr-manual.md, br/br-pitr-guide.md
新增 tiup br restore point --help 中的参数说明、PITR 示例、多步恢复规则、错误信息和相关限制。

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~8 minutes

Change: Other

Merge Risk: 🔵 Low · up to 838eb

Users restoring PITR from incremental backups may not know whether --rename is supported, risking a failed restore or incorrect command choice.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次变更:补充 BR restore 的 --rename 文档。标题简洁、明确,并与主要改动一致。
Description check ✅ Passed 描述包含变更内容、适用版本、相关链接、AI 参与情况和其他必要检查项。变更说明具体,并覆盖各文档文件、功能限制及实验特性警告。相关链接为空不影响通过,因为模板将其标记为可选信息。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 9f8e0f35-620b-4649-b780-b60eebb97c56

📥 Commits

Reviewing files that changed from the base of the PR and between 924e58f and 574f99f.

📒 Files selected for processing (7)
  • br/backup-and-restore-overview.md
  • br/br-incremental-guide.md
  • br/br-pitr-guide.md
  • br/br-pitr-manual.md
  • br/br-snapshot-guide.md
  • br/br-snapshot-manual.md
  • br/use-br-command-line-tool.md

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread br/br-pitr-manual.md
Comment thread br/br-snapshot-manual.md Outdated
@LykxSassinator

Copy link
Copy Markdown
Contributor Author

For release-note:

Please add the following parts into releate-note:

### 数据迁移

   * BR 支持在恢复时将数据恢复到不同的库表名(实验特性)[#51711](https://github.com/pingcap/tidb/issues/51711) @[LykxSassinator](https://github.com/LykxSassinator) <!-- component: br --> <!-- pr:
 https://github.com/pingcap/tidb/pull/70590 -->

       从 v9.0.0 起,BR 支持在恢复时通过 `--rename` 指定重命名规则,把备份数据恢复到与备份时不同名的数据库或表。`--rename '源库名:目标库名'` 用于库级别重命名,`--rename '源库名.源表名:目标库名.目标表名'` 用于表级
 别重命名。该参数可以重复指定,库表名匹配不区分大小写,且表级规则优先于库级规则。

       该功能适用于把备份数据恢复到仍在使用原库表的同一个集群,例如数据核对、回滚验证或离线分析。恢复后源库表不受影响;目标数据库可以已存在并被复用,但目标表必须不存在。重复的源、重复的目标、多个源对象落到同一个
 目标、规则未命中任何对象,以及目标表已存在等情况,都会在执行任何 DDL 之前报错。该功能支持全量快照恢复和 PITR(含快照恢复与后续的纯日志恢复),不支持增量快照恢复、RawKV/TxnKV 恢复,也不能与 `--no-schema` 同时使用
 。

       更多信息,请参考[快照恢复用户文档](https://docs.pingcap.com/zh/tidb/v9.0/br-snapshot-manual)和 [PITR 用户文档](https://docs.pingcap.com/zh/tidb/v9.0/br-pitr-manual)。

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Outside the diff (1)

🟡 Minor · 明确增量源 PITR 的 --rename 边界。

br/br-pitr-manual.md:565-590
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

明确增量源 PITR 的 --rename 边界。

br/br-pitr-manual.md:412 允许 --full-backup-storage 指向增量备份地址,但 br/br-incremental-guide.md:24 禁止增量恢复使用 --rename。本节只展示了全量快照作为源的 PITR 示例,未说明该限制是否适用于 restore point 的增量源模式。请明确该组合是否支持 --rename;如果支持,请说明必须设置 --allow-pitr-from-incremental=true,否则请明确禁止该组合。


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5fa578de-3ff4-4f43-829b-d9fc6217c8c8

📥 Commits

Reviewing files that changed from the base of the PR and between 574f99f and 838ebf7.

📒 Files selected for processing (1)
  • br/br-snapshot-manual.md

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant