Status: Reviewed (deep-dive v1)
Stack: PowerShell collect → SQL store/procs → Blazor Server UI
Depends on: SQL-01 Inventory (population list = managed instances)
Goal: Know every database is backed up to policy, restorable, and visible when it isn’t.
Inventory tells you what exists. Backup readiness tells you whether you can survive losing it. Fix coverage gaps before optimizing indexes.
| Class | Example | RPO (start) | Full | Diff | Log |
|---|---|---|---|---|---|
| A — Critical | OLTP prod, auth, billing | ≤ 15 min | Daily | Every 4–6 h | Every 5–15 min |
| B — Standard | Internal apps | ≤ 1–4 h | Daily | Daily / every 12 h | Every 15–30 min (FULL) |
| C — Low | Dev/test, scratch | ≤ 24 h | Daily or weekly | Optional | SIMPLE often OK |
SIMPLE recovery → no log backups required; still need full (+ optional diff).
Do not invent final estate policy — use these as scaffolding until Rick sets real targets.
Scope = instances from inventory (LastSeenAt fresh). Prefer T-SQL via Invoke-Sqlcmd / SMO against msdb + sys.databases.
msdb.dbo.backupset / backupmediafamily)CollectedAt, instance key (host + instance), per-db rowsKeep it read-only on prod. No BACKUP DATABASE from the collector.
| Table | Purpose |
|---|---|
dbo.DbBackupClass |
Class name, RPO minutes, full/diff/log interval targets |
dbo.SqlDatabase |
DB identity tied to SqlInstance |
dbo.SqlDatabaseBackupStatus |
Latest backup timestamps + computed gap flags |
dbo.SqlDatabaseBackupHistory |
Optional trim of recent backupset facts |
dbo.BackupPolicyException |
Approved gaps (who/when/why) |
Procs:
usp_SqlDatabase_Upsert — merge DBs from collectusp_SqlDatabaseBackupStatus_Apply — upsert latest times; set FullOverdue, LogOverdue, NoFullEver, RecoveryMismatchusp_BackupCoverage_GetHeatmap — Blazor: instance × DB with RAG statususp_BackupCoverage_GetFailures — queue of overdue / failedusp_BackupPolicyException_List — suppress known exceptions in UI (still visible under Exceptions)Scoring idea (simple):
Drive grids from procs only.
Backing up ≠ restorable. Lean program:
RESTORE VERIFYONLY or full restore + smoke query)RestoreTestRun (db, as-of time, result, operator, notes)PS can orchestrate restore to a dedicated verify instance; SQL stores results; UI shows freshness.
msdb history on that instance| Symptom | Likely cause |
|---|---|
| Never a full | Job missing / filtered DB / new DB not in maintenance plan |
| Log overdue, FULL | Log job stopped; AG backup on wrong replica; log VLFs/disk full |
| Only copy_only fulls | Ad-hoc backups; scheduled job not running true fulls |
| Green in msdb, file gone | Retention script; wrong path; share moved |
| Diff without base full | Broken chain after file restore / recovery model flip |
VIEW ANY DEFINITION / read msdb backup tables; public-ish minimum via custom role preferredIndex & statistics maintenance — safer once backup coverage is trusted.
SQL Dude — SQL-02 Backup & Restore Readiness v1