PITR Browser — Point-in-Time Restore
Cosmos 有 continuous backup(7d 或 30d),但 restore 只能通过 az-cli 或 portal 运行。专用 UI 带 horizon 的可视化 timeline、restore plan 验证器、带所有参数的 `az cosmosdb restore` 命令生成器 + 通过 host shell 执行的选项。用于 DR drill、生产 bug 恢复、为 WHAT-IF Lab 创建 sandbox。
它在应用中的位置: Tools → Cosmos DB → PITR — Point-in-Time Restore
它做什么
- Continuous-backup window 的可视化 timeline(默认 7d 或 30d)。
- Plan 验证器:timestamp 在 horizon 内、target account name 唯一、region 有效。
- 带 source/target/restorePoint/region 的 `az cosmosdb restore` 命令生成器。
- "Run via host shell" 按钮通过 IPC 执行(需要已登录 az-cli)。
- 审计跟踪(v2 surface 由应用触发的 restores 列表)。
分步
- 1
打开 PITR Browser
Tools → Cosmos DB → PITR — Point-in-Time Restore。通过 submenu 的快捷方式。
- 2
选择 source account + backup 类型
输入 source Cosmos account 的名称 + 类型(continuous-7d / continuous-30d / periodic)。
- 3
选择 restore timestamp
ISO-8601 格式(例如 2026-05-24T12:34:56Z)。必须在 timeline 中显示的 horizon 内。
- 4
定义 target account name
新 Cosmos account 的名称,snapshot 将在此变为 live account。Auto-suggest "<source>-restored-<timestamp>"。
- 5
验证 plan
"Validate plan" 按钮 — 检查:timestamp 在 horizon 内、不在未来、account name 唯一。Banner success/error。
- 6
执行(CLI 或 shell)
推荐模式:"Copy CLI" 在外部特权 shell 中执行。便捷模式:"Run via host shell" 使用 Electron IPC,如果 az-cli 会话活动。
az cosmosdb restore \ --target-database-account-name my-cosmos-restored-1234567 \ --account-name my-cosmos-account \ --resource-group my-rg \ --restore-timestamp 2026-05-24T12:34:56Z \ --location eastus
- 7
在 portal 中跟踪
Restore 根据数据集需要 30 分钟到 24 小时。Portal 在 resource group 中显示进度。
真实用例
生产中的错误迁移
团队进行了错误的 `dropIndex` migration,删除了关键 index。通过 PITR 回滚到 2h 之前 — 无 post-recovery 数据丢失(通过 Change Feed 合并)。
合规演练
SOC 2 审计要求 PITR 演示。DBA 通过 UI 在 30 分钟内将 restore 到 sandbox account。审计师满意。