PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Planning review
- 1.1 Pass the planning review gate. The review hooks run it automatically when they are active. When they are disabled, run the reviewer subagent on proposal.md, the backup-schedule-visibility spec, design.md and this task list. Resolve every CHANGES REQUIRED finding before writing code
2. Next-trigger calculation
- 2.1 Add the invariant test from design decision 2 to
backend/internal/features/intervals/model_test.go, written againstGetNextTriggerandNextTrigger. It covers hourly, daily, weekly, monthly and cron schedules, a missing last backup, a missed daily slot, a weekly slot missed in an earlier week, monthly days 29, 30 and 31 across February and 30-day months, and a cron catch-up. Add separate cases that expect nil for invalid intervals: unknown type, missing or malformed time of day, missing weekday or day of month, missing or unparsable cron expression. Verify that the test fails to compile or fails before 2.2, withgo test ./internal/features/intervals/... -count=1 - 2.2 Replace
Interval.NextTriggerTimewithGetNextTriggerand add theNextTriggertype.IsDuecomes fromShouldTriggerBackup. When it is due,ScheduledAtisnow, otherwise the per-type slot. Rewrite the monthly slot to skip months without the configured day. Return nil for every interval the slot functions cannot evaluate. DeleteNextTriggerTimeand rewrite theTestInterval_NextTriggerTime_*cases for the new function. Verify withgo test ./internal/features/intervals/... -count=1
3. Logical backend
- 3.1 Add
FindBackupConfigByDbIdto the logicalBackupConfigService. It returns nil when no config exists and never inserts one - 3.2 Add
GetNextScheduledBackupResponsetobackend/internal/features/backups/backups/dto/logical, withNextBackup *intervals.NextTrigger - 3.3 Add
BackupsScheduler.GetNextScheduledBackup(databaseID, now). It returns nil when no config exists, backups are disabled or storage is missing. Otherwise it appliesGetNextTriggerto the newest backup of any status throughFindLastByDatabaseID. Verify through the controller tests in 3.5 - 3.4 Add
LogicalBackupService.GetNextScheduledBackup(ctx, user, databaseID). It authorizes throughDatabaseService.GetDatabaseand then rejects a physical database as a bad request. AddGET /backups/database/:id/next-backupwith swagger annotations to the logical backups controller - 3.5 Add controller tests: daily schedule with a future slot, missed slot reported as due, no backups reported as due, disabled backups return a null next backup, missing storage returns a null next backup, a database without saved backup settings returns a null next backup and gains no config row, a physical database is rejected with 400, a user outside the workspace is rejected, and an unauthenticated request is rejected. Verify with
go test ./internal/features/backups/backups/controllers/logical/... -count=1
4. Physical backend
- 4.1 Add
FindBackupConfigByDbIdto the physicalBackupConfigService. It returns nil when no config exists and never inserts one - 4.2 Add
GetNextScheduledBackupsResponsetobackend/internal/features/backups/backups/dto/physical, withNextFullBackupandNextIncrementalBackupas*intervals.NextTrigger - 4.3 Add
PhysicalBackupsScheduler.GetNextScheduledBackups(databaseID, now)as design decision 3 describes. It reports nothing when no config exists, backups are disabled, storage is missing or an identity mismatch is unresolved. The full time comes from the newest full of any status. The incremental time is reported only when incremental backups are enabled and the chain is not held back, and comes fromnewestCreatedAt. If the held-back condition is extracted fromdecideReAnchoringFullinto a shared predicate, verify that the tick is unchanged withgo test ./internal/features/backups/backups/backuping/physical/... -count=1 - 4.4 Add
PhysicalBackupService.GetNextScheduledBackups(ctx, user, databaseID). It authorizes throughDatabaseService.GetDatabaseand then rejects a non-physical database as a bad request. AddGET /backups/physical/database/:id/next-backupswith swagger annotations to the physical backups controller - 4.5 Add controller tests: full and incremental both reported, full-only configuration reports no incremental, full plus incremental plus WAL stream reports both, disabled backups report neither, missing storage reports neither, an unresolved identity mismatch reports neither, a chain broken by WAL summarization being off reports full only, no completed full among the newest attempts reports full only, a logical database is rejected with 400, a user outside the workspace is rejected, and an unauthenticated request is rejected. Verify with
go test ./internal/features/backups/backups/controllers/physical/... -count=1 - 4.6 Regenerate swagger with
make swaggerand confirm both new routes appear in the generated docs
5. Frontend
- 5.1 Add
ScheduledBackupTimeunderfrontend/src/entity/backups/shared/model,NextScheduledBackupResponseunderlogical/modelandNextScheduledBackupsResponseunderphysical/model, one type per file and exported through each slice'sindex.ts. AddlogicalBackupsApi.getNextScheduledBackupandphysicalBackupsApi.getNextScheduledBackups - 5.2 Add the new strings to
frontend/src/shared/i18n/locales/en.tsand translate them inru.ts,es.ts,pt.ts,zh.tsandfr.ts: card next backup, next full and next incremental lines, the settings line, and a due-now variant of each. Verify thatpnpm buildpasses type checking of every dictionary - 5.3 Add a pure helper
isScheduledBackupDue(scheduledBackupTime, now)next toScheduledBackupTime, true whenisDueis set orscheduledAtis not afternow, with a vitest test covering both flags and the boundary. Verify withpnpm test - 5.4 Render the next backup under "Last backup" in
DatabaseCardComponent. Load it in its own effect keyed on thedatabaseobject, so it refreshes with every list reload. Render one line for logical databases and two for physical ones. Show the due-now text whenisScheduledBackupDueholds, and no line when the response has none. Verify withpnpm lintandpnpm build - 5.5 Replace the browser-side cron "Next run" block in
ShowLogicalBackupConfigComponentwith the API-backed next backup line for every interval type, usingisScheduledBackupDue, and delete itscron-parserusage. Verify withpnpm lintandpnpm build - 5.6 Replace
renderCronNextRuninShowPhysicalBackupConfigComponentwith API-backed lines under the full and incremental schedules, usingisScheduledBackupDue, and delete itscron-parserusage. Verify withpnpm lintandpnpm build
6. Verification and review
- 6.1 Run
make lintinbackend/, andpnpm lint,pnpm testandpnpm buildinfrontend/. Fix every failure - 6.2 From
backend/, rerun the packages this change touches and fix every failure:go test ./internal/features/intervals/... ./internal/features/backups/config/... ./internal/features/backups/backups/backuping/... ./internal/features/backups/backups/controllers/... -count=1 - 6.3 Pass the final review gate. The review hooks run it automatically when they are active. When they are disabled, run the reviewer subagent on the working-tree diff. Resolve every CHANGES REQUIRED finding and list refactor suggestions for the diff