PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Test fixture
- 1.1 Add a
WithMaxWalSenders(n)option to the physical PostgreSQL test container besideWithMaxConnectionsinbackend/internal/util/testing/containers/postgres_physical.go, overriding the hard-codedmax_wal_senders=10. Verify withgo build ./...frombackend/.
2. Liveness probe on the physical model
- 2.1 Add
PostgresqlPhysicalDatabase.ProbeLiveness(ctx, logger, encryptor)inpostgresql/physical/model.go, next toTestReplicationConnection: an ordinary connection throughopenConn,SELECT 1, a 30-second timeout derived fromctx, and the driver error returned wrapped and unclassified. Verify withgo build ./...frombackend/. - 2.2 In
postgresql/physical/model_test.go, addTest_ProbeLiveness_WhenWalSendersExhausted_Succeeds: start a source withWithMaxWalSenders(1), hold the slot with an open replication connection, then assert thatProbeLivenesssucceeds and thatTestReplicationConnectionfails, so the fixture is proven to have exhausted the slot. Verify withgo test ./internal/features/databases/databases/postgresql/physical/... -run Test_ProbeLiveness -count=1. - 2.3 In the same file, add
Test_ProbeLiveness_WhenPasswordIsWrong_FailsWithoutLeakingPassword: the probe returns an error, the error carries the server's authentication refusal, and the error text does not contain the wrong password. Verify with the same command as 2.2.
3. Type dispatch
- 3.1 Add
Database.ProbeLiveness(ctx, logger, encryptor)indatabases/model.go: a physical source with a nilPostgresqlPhysicalreturns "postgresql physical config is not set", a physical source callsPostgresqlPhysical.ProbeLiveness, and every other type runsTestConnection. The doc comment explains why non-physical types still run their full connection test: they share no replication capacity with backups, so nothing needs protecting there. Verify withgo build ./...frombackend/. - 3.2 In
databases/model_test.go, addTest_ProbeLiveness_ForEveryDatabaseType_WithoutEngineConfig_ReturnsErrorInsteadOfPanicking, mirroring the existingTestConnectioncase table. Verify withgo test ./internal/features/databases/ -run Test_ProbeLiveness -count=1.
4. Wire the healthcheck to the probe
- 4.1 Rename
DatabaseService.TestTrustedDatabaseConnectiontoProbeDatabaseLivenessand give it its own body: open the tunnel throughOpenTunnel, then callProbeLivenesson the tunneled copy. LeavetestDatabaseConnectionserving the workspace-authorized path only. Delete the old name. Verify thatgrep -rn TestTrustedDatabaseConnection backend/returns nothing and thatgo build ./...passes. - 4.2 Rename the method on the healthcheck
DatabaseServiceinterface, onMockDatabaseService, at the call site inCheckDatabaseHealthUseCase, and incheck_database_health_uc_test.go. Verify withgo test ./internal/features/healthcheck/... -count=1. - 4.3 In a new
databases/service_test.go, addTest_ProbeDatabaseLiveness_WithEmbeddedPhysicalTarget_ReturnsError, which pins that the trusted path still refuses an embedded target before any connection opens. Verify withgo test ./internal/features/databases/ -run Test_ProbeDatabaseLiveness -count=1. - 4.4 In the same file, add
Test_ProbeDatabaseLiveness_WhenSourceIsBehindSshBastion_Succeeds, usingcontainers.StartPhysicalPostgresBehindSshBastion. Verify with the same command as 4.3.
5. Verification and review
- 5.1 Run
make lintinbackend/and fix every finding in the touched files. - 5.2 Run the touched packages from
backend/and confirm that they pass:go test ./internal/features/databases/... ./internal/features/healthcheck/... -count=1. - 5.3 Run the reviewer subagent on the working-tree diff and resolve every CHANGES REQUIRED finding.
- 5.4 Run
openspec validate physical-healthcheck-liveness-probe --strictand confirm that it passes.