驗證¶
沒人還原過的備份只是一種希望。Tenax 會依排程還原你的備份、檢查它們,並把通過檢查的備份標記為已驗證。
in a BackupPolicy
spec:
verify:
schedule: "17 4 * * 0" # weekly, Sunday 04:17 in the policy's time zone
checks: [inventory-matches, row-estimates-within-10pct, target-checks]
randomPointInTime: true # also restore a random second inside the window
到了排程時間,控制器會從最新的備份建立一個還原到沙盒的 Restore;如果存在變更串流,還會從時間窗內的一個隨機時間點再還原一次。
然後執行以下檢查:
| 檢查 | 通過條件 |
|---|---|
inventory-matches |
還原出的表和 schema 指紋與備份的清單一致。 |
schema-matches |
schema 指紋一致。 |
row-estimates-within-NNpct |
每張表的列數與清單中的估計值相差不超過 NN %。 |
target-checks |
目標上宣告的每個 SQL 檢查都傳回 true。 |
目標檢查是普通的 SQL,必須傳回單個 true 值:
in a BackupTarget
spec:
checks:
- name: orders-not-empty
database: app
sql: select count(*) > 0 from orders
- name: recent-orders
database: app
sql: select max(created_at) > now() - interval '2 days' from orders
通過的執行會給備份打上 verified 標籤並記錄還原耗時,以 tenax_verify_rto_seconds 匯出。失敗的執行會觸發
TenaxVerificationFailed;連續 8 天沒有成功的執行會觸發 TenaxVerificationOverdue。可以用
tenax verify team-a/app --wait 手動執行一次,或在目標頁面上點選 立即驗證。