Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

13.0 KB
Raw Blame

1. Latest restorable moment in the API

  • 1.1 Split ResolveRestoreSet in core/physical/chain_view/restore_set.go into a private latest-reach resolution and the existing target checks, and add ChainViewService.GetLatestRestorableAt returning the reachable time or nil without a chain (design D1). Verify with just test-package ./internal/features/backups/backups/core/physical/chain_view/... in backend/.
  • 1.2 Add latestRestorableAt to GetWalStreamStatisticsResponse and fill it in services/physical_wal_stream_statistics.go, with controller tests for no gaps, a gap in the newest chain, an incremental backup completed after the gap, a full backup without WAL and no full backup. Verify with just test-package ./internal/features/backups/backups/controllers/physical/... in backend/.
  • 1.3 Describe the field in the endpoint's Swagger annotation and regenerate the docs with swag init -d . -g cmd/main.go -o swagger in backend/. Verify that grep -c latestRestorableAt backend/swagger/swagger.yaml is above zero and that just lint in backend/ passes.

2. Frontend rules and strings

  • 2.1 Add latestRestorableAt to the WalStreamStatistics model in entity/backups/physical/model, and add the new keys of design D8 to all six interface dictionaries. Verify with pnpm --dir frontend typecheck and pnpm --dir frontend test src/shared/i18n.
  • 2.2 Map WAL_CHAIN_BROKEN to no stage in REASON_STAGES and skip it in getStageTones (design D7), with a test that a broken chain alone leaves every stage healthy. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/pathStages.test.ts.
  • 2.3 Add the pure full backup action function of design D3, with tests for available on a broken chain, available on a missing slot, available on a healthy verdict without a completed full backup, hidden without manage permission, hidden without a reason, hidden for not streaming, hidden for collecting data, hidden while unconfirmed, hidden while a full backup is pending, requesting while the flag is set, and available again once the flag clears after a failed request. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib.
  • 2.4 Extend getVerdictBanner to compose the headline, the headline reason, the other reasons and the restore sentence (design D2), with tests for the healthy headline, a reason title as headline, broken reasons before needs-attention ones, all four restore sentence cases, a broken chain whose moment already reaches the newest archived segment getting the plain sentence, the restore sentence during collecting data without a full backup, a moment from today and from an earlier day, and the unconfirmed state keeping the last known moment. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/verdictBanner.test.ts.
  • 2.5 Add hasEnoughChartPoints, getChartTimeDomain and getAmountAxisMaximum to chartRows.ts and remove hasAnyChartValues (design D6), with tests for three and four points, data starting inside the period, data covering the whole period and the minimum top. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/chartRows.test.ts.
  • 2.6 Add getMonitoringFigures (design D4), with tests for the busy healthy case (15 seconds ago, 20 MB, 10 MB/s against 10 MB/s), null rates when no sample in the window holds a write value, and null for the collecting data and not streaming verdicts. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/monitoringFigures.test.ts.

3. Frontend layout

  • 3.1 Rebuild VerdictBannerComponent around the composed banner: headline, headline reason, compact other reasons, restore sentence and the full backup button wired to physicalBackupsApi.triggerPhysicalBackup(database.id, 'full'), with WalStreamRefreshController.retry() after success and errors through translateApiError. Pass isCanManageDBs from DatabaseComponent to the tab, and delete MonitoringReasonsComponent. Verify with pnpm --dir frontend typecheck and pnpm --dir frontend test src/features/backups/physical/monitoring.
  • 3.2 Add the figures row from getMonitoringFigures, rendering unknown values as "not measured", with the keeping-up sentence and its consequences as its caption (design D4), and drop the unknown sentence from getKeepingUpSentences. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/monitoringFigures.test.ts src/features/backups/physical/monitoring/lib/keepingUpSentences.test.ts and pnpm --dir frontend typecheck.
  • 3.3 Show one main chart with the new time domain, amount axis minimum and empty state, and add the collapsed tips and technical details sections holding the notices, the path of changes, the two secondary charts and the raw values (design D5, D6). Put the arrow classes on wrapper elements (design D7). Verify with pnpm --dir frontend typecheck and pnpm --dir frontend lint.
  • 3.4 Update WalStreamMonitoringSections.test.tsx for the healthy banner, the broken chain banner with its restore sentence and button, no button for a read-only user, the figures row with "not measured", the collapsed tips header with its count, the technical details body showing the path of changes, both secondary charts' titles and the raw values, the "not enough data" and "data since" chart captions, and each arrow icon inside a wrapper carrying its breakpoint class. Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/ui.
  • 3.5 Remove the dictionary keys and helpers only the deleted blocks used from all six dictionaries and the slice, then run the frontend checks. Verify with pnpm --dir frontend lint, pnpm --dir frontend typecheck, pnpm --dir frontend test and pnpm --dir frontend build.

4. Restore coverage and the broken chain verdict

  • 4.1 Add ChainViewService.GetRestoreCoverage with the latest restorable moment, the merged restorable ranges and the gaps the latest restore cannot cross, and remove GetLatestRestorableAt (design D1). Cover it with chain_view tests for no full backup, contiguous WAL, a gap without an incremental, a gap bridged by a completed incremental, an incremental before the gap, a failed, chain-broken or running incremental after the gap, two gaps with only the first bridged, an incremental stopping inside a missing segment, a segment still uploading and a newer full backup, each checking that the last range ends at the latest restorable moment. Verify with just test-package ./internal/features/backups/backups/core/physical/chain_view/... in backend/.
  • 4.2 Write the controller test for a bridged gap with a streamer and samples, and see it fail with WAL_CHAIN_BROKEN on the current code. Then pass the blocking gaps to the verdict, rename NewestChainGaps to RestoreBlockingGaps, and add restorableRanges to the response and its Swagger description. Add controller tests for a gap after the newest incremental, a failed incremental after the gap and no full backup, and cover restorableRanges in the response format check. Verify with just test-package ./internal/features/backups/backups/controllers/physical/... ./internal/features/backups/backups/core/physical/wal_health/... and just lint in backend/.

5. Restore timeline, figure cards, chart and banner

  • 5.1 Add restorableRanges to the WalStreamStatistics model and the test fixture, add getRestoreTimeline with tests for one range, a gap between two ranges, the minimum width of a short gap and the not saved yet tail, and render RestoreTimelineComponent between the figures and the main chart (design D10). Simplify isRestoreLimitedByBrokenChain to the reason alone (design D2). Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib.
  • 5.2 Turn the figures into four cards with the chart's rate labels and colors, and remove figures.speed and figures.speedValue (design D4). Verify with pnpm --dir frontend typecheck.
  • 5.3 Add getBinaryAxisTicks and getMissingDataRanges with tests, replace getAmountAxisMaximum, and rebuild the chart header, legend, height, saved-to-storage band and missing data shading and caption (design D6). Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib/chartRows.test.ts.
  • 5.4 Limit the banner's text width, move the measured label into the headline row, leave out the headline reason's "what to do" sentence while the full backup button shows, and rewrite the broken chain's "what happened" sentence in all six dictionaries (design D2, D11). Return null from the duration helpers for non-finite input and use the restore sentence without an age then, with tests (design D12). Verify with pnpm --dir frontend test src/features/backups/physical/monitoring src/shared/i18n.
  • 5.5 Update WalStreamMonitoringSections.test.tsx for the four figure cards, the timeline's lost-stretch sentence, and the "what to do" sentence hidden next to the button and shown without it. Run the frontend checks, and check the tab in a browser at 1240, 1440 and 2560 px. Verify with pnpm --dir frontend lint, pnpm --dir frontend typecheck, pnpm --dir frontend test and pnpm --dir frontend build.

6. Current values every second and the pipeline

  • 6.1 Remember the newest slot probe in WalStreamSupervisor, add GetLiveState, keep each running supervisor on runningStreamer with PhysicalWalStreamSupervisor.GetLiveState(databaseID), and add GET /backups/physical/database/:id/wal-stream/live with its Swagger description (design D13). Cover it with controller tests for a viewer reading a streamer's values, a database without a running streamer, a user without access and a logical database. Verify with just test-package ./internal/features/backups/backups/controllers/physical/... ./internal/features/backups/backups/backuping/physical/..., just test-package -run Test_GetLiveState ./internal/features/backups/backups/usecases/physical/postgresql/ and just lint in backend/.
  • 6.2 Add WalStreamLiveController reading the current values every second while visible, with tests for the schedule, a hidden tab, a failed reading and stop, and overlay newer live values onto the statistics for the figures, the restore timeline and the path of changes (design D13). Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib.
  • 6.3 Rebuild ChangesPathComponent as the pipeline of design D14, return neutral from getStageTones for a stage without a reason, and update its static-markup test. Verify with pnpm --dir frontend lint, pnpm --dir frontend typecheck, pnpm --dir frontend test and pnpm --dir frontend build, and check it in a browser at 1240, 1440 and 2560 px.

7. Width, open sections and a consistent restore moment

  • 7.1 Write the Test_GetLiveState case for an archive progress point past the probed position and see it fail with an unknown amount, then report zero (design D13). Verify with just test-package ./internal/features/backups/backups/usecases/physical/postgresql/ -run Test_GetLiveState and just lint in backend/.
  • 7.2 Move the restore point and the end of the newest restorable range with the live save while the statistics' restore point equals their newest save, and name the newest restorable stretch's start in the restore sentence when an earlier stretch cannot be restored, with tests and the two new keys in all six dictionaries (design D2, D13). Verify with pnpm --dir frontend test src/features/backups/physical/monitoring/lib src/shared/i18n.
  • 7.3 Cap the tab at max-w-6xl, use fixed chart heights, a 64 KiB/s rate axis minimum and text-xl values, lay out the path of changes by a container query, and show the technical details and the tips without a Collapse, removing the tips title from all six dictionaries (design D5, D6, D11). Update the static-markup tests and check the tab in a browser at 1240, 1440 and 2560 px. Verify with pnpm --dir frontend lint, pnpm --dir frontend typecheck, pnpm --dir frontend test and pnpm --dir frontend build.
  • 7.4 Rebuild ChangesPathComponent as the flow strip of design D14: one frame, a subgrid row of icons, titles and lines with the rates on the lines, "nothing waiting" for an empty queue, limit sentences only above zero, and the averages caption; mark the two rate cards as 10-minute averages; add path.nothingWaiting, path.ratesCaption and figures.averageHint and remove path.noAllowanceLimit in all six dictionaries. Update the static-markup tests and check the strip in a browser at 900, 1240 and 1440 px. Verify with pnpm --dir frontend lint, pnpm --dir frontend typecheck, pnpm --dir frontend test and pnpm --dir frontend build.

Change verification

just test-package ./internal/features/backups/backups/core/physical/chain_view/... ./internal/features/backups/backups/core/physical/wal_health/... ./internal/features/backups/backups/controllers/physical/...
just test-package ./internal/features/backups/backups/usecases/physical/postgresql/...
pnpm --dir frontend test src/features/backups/physical/monitoring src/shared/i18n