PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Backend: grouped list with a cursor
- 1.1 Replace
ListBackupsincore/physical/service/service.gowith the CTE chain from design D1 (gap flag over committed WAL, filter, time-ordered grouping, range aggregation, keyset page oflimit + 1). ExtendPhysicalBackupListRowwith the range fields and the sort time, and deleteCountBackups. Verify withgo build ./...frombackend/. - 1.2 Change the physical list DTOs and service per design D2: the request takes
cursorinstead ofoffset; the response carriesbackups,totalUsageMbandnextCursor;PhysicalBackupListItemdropswalFilenameand gainsfromWalFilename,toWalFilename,walSegmentsCountandhasGapBefore. Add cursor encoding and decoding in the service, and update the controller's swagger annotations. Verify withgo build ./...andmake swagger. - 1.3 Rewrite the paging controller tests in
controllers/physical/controller_test.gofor the cursor: followingnextCursorreturns the next rows; a FULL created between two requests causes no repeat or skip; the last page has no cursor; a malformed cursor returns 400; a cursor from another database returns only the requested database's rows; a user without access is rejected with a cursor. Delete the offset andtotaltests. Verify withgo test ./internal/features/backups/backups/controllers/physical/... -count=1. - 1.4 Add controller tests for WAL ranges, one per scenario in
specs/physical-backup-wal-ranges/spec.md: one range for contiguous segments with correct count, size, from/to names and times; a split andhasGapBeforeat a missing segment; no gap mark on the oldest range or on a new timeline's first range; a split at a timeline switch; a split around a FULL; one range across a FULL when filtering to WAL; a before-date filter that cuts a range; a status filter that hides all WAL; a range that keeps its id and grows after another contiguous segment is added; a range that counts as one row toward the limit. Usephysical_testing.CreateTestWalSegmentwith explicit LSNs andReceivedAt. Verify withgo test ./internal/features/backups/backups/controllers/physical/... -count=1. - 1.5 Switch
committedWalSegmentsInOrderandstreamPostFullSegmentsinfeatures/tests/physical/postgresql/shared/helpers.goto read committed segments throughGetWalSegmentRepository().FindByChainSpan(design D8), and update their callers inshared/bodies.go. DeletelistBackupsByTypeif it has no callers left. Verify withgo vet ./internal/features/tests/.... - 1.6 Run
make lintfrombackend/and fix every finding.
2. Backend: query cost check
- 2.1 Insert 50 000 committed segments on one timeline plus a FULL every 10 000 segments for a test database, then run
EXPLAIN (ANALYZE, BUFFERS)on the first-page query and on a cursor page deep in the list. Record the timings and plan shape under Risks indesign.md. Compare the result with the 100 ms per-request budget and record indesign.mdwhether the change ships the on-the-fly query or needs the stored range table from D1.
3. Frontend: shared paging
- 3.1 Add
shared/lib/pagedList.ts(design D4) withmergeRefreshedFirstPageandappendNextPage, andpagedList.test.tscovering deduplication on append and, for the merge: only the first page loaded; new rows at the top with a deep loaded tail; a changed row in place; the first page's last key missing, which falls back to the first page; two ranges merged under the older range's id; an empty first page; no duplicate keys in any result. Export it fromshared/lib/index.ts. Verify withpnpm test. - 3.2 Add
shared/hooks/usePolledPagedList.ts(design D4): loaded rows, next cursor,isLoading,isLoadingMore,hasMore,reload(), the scroll listener, the refresh interval with an in-flight guard, deduplication on append, and a reset generation that discards stale responses. Export it fromshared/hooks/index.ts. Verify withpnpm lintandpnpm build. - 3.3 Move the paging rules out of the hook into
shared/lib/PagedListController.ts, a class with no React state that the hook wraps, and cover it withPagedListController.test.ts: reload loads the first page; the next page is requested with the stored cursor and appended; nothing is requested after the last page; a refresh requests only the first page and keeps the scrolled tail; a second refresh or next-page request is skipped while one is in flight; a refresh or next page that answers after a reload is dropped; only errors of the current list are reported. Verify withpnpm test.
4. Frontend: physical backup list
- 4.1 Update
entity/backups/physical:PhysicalBackupListItemgets the range fields and loseswalFilename;GetPhysicalBackupsResponsegetsnextCursorand losestotal,limitandoffset;getPhysicalBackupstakes a cursor instead of an offset. Verify withpnpm build, which reports every consumer still using the old shape. - 4.2 Move
PhysicalBackupsComponentontousePolledPagedListwith a 1 s refresh. DeletecurrentLimit,loadMoreBackups,lastRequestTimeRefand the component's own scroll and interval effects. Trigger, delete, filter change and database change callreload(); cancel refreshes only the first page (design D5). Remove the clientsorteranddefaultSortOrder(design D6). The "all loaded" line shows the number of loaded rows. Verify withpnpm lintandpnpm build. - 4.3 Render WAL range rows per design D7 and add the
backups.physical.list.walRangekeys toen.tsand every other locale. Verify withpnpm lint,pnpm test(the dictionary placeholder check) andpnpm build. - 4.4 Move the type cell into
PhysicalBackupTypeCellComponentand cover its rendering withPhysicalBackupTypeCellComponent.test.tsx: a WAL range shows the segment count and its first and last segment names; a range after a gap shows the gap tag and one without does not; a single-segment range shows one name; a backup shows only its type badge. Verify withpnpm test.
5. Frontend: logical backup and restore check lists
- 5.1 Move
LogicalBackupsComponentontousePolledPagedListwith an offset adapter (design D3) and keep its 1 s refresh. Delete itscurrentLimitpaging,loadMoreBackupsand its own scroll and interval effects. Verify withpnpm lintandpnpm build. - 5.2 Move
VerificationsComponentontousePolledPagedListthe same way and keepVERIFICATIONS_REFRESH_MS. Leave the agent availability polling as it is. Verify withpnpm lintandpnpm build.
6. Verification
- 6.1 Run
pnpm format,pnpm lint,pnpm testandpnpm buildfromfrontend/, andmake lintfrombackend/. Fix every failure.