PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Refuse a streaming configuration the source cannot support
- 1.1 Add
canForceWalRotationin a newbackend/internal/features/databases/databases/postgresql/physical/forced_wal_rotation.go: a read-only check answering whether a named role can executepg_switch_wal(), viahas_function_privilegeover the ordinary connectioncheckReplicationReadinessalready opens (model.go:824). Verify against a real PostgreSQL container withTest_CanForceWalRotation_ForReplicationOnlyRole_ReturnsFalseandTest_CanForceWalRotation_AfterExecuteIsGranted_ReturnsTrue, both dropping their roles through the existingcreateTempUsercleanup. - 1.2 Confirm the probe answers for the role passed in rather than for the connected administrator:
Test_CanForceWalRotation_WhenAnAdminProbesAnotherRole_AnswersForThatRoleconnects as the superuser fixture, asserts the administrator can rotate, and asserts a replication-only role cannot. This is the false-positive trap named indesign.md; without it the probe reports success on every platform. It stays a container-backed model test because no endpoint reaches the case of probing one role while connected as another. - 1.3 Add
ConnErrNoWalSwitchPrivilegetobackend/internal/features/databases/databases/postgresql/shared/connection_error.goand the gate tocheckReplicationReadiness, next to thesummarize_walcheck it mirrors (model.go:852): whenBackupType.IsWalStreaming()and the probe says the role cannot executepg_switch_wal(), return that code. Verify withTest_TestDatabaseConnectionDirect_ForWalStreamWhenRoleCannotSwitchWal_ReturnsNoWalSwitchPrivilegeCodeonPOST /databases/test-connection-direct. - 1.4 Verify the accepting path with
Test_TestDatabaseConnectionDirect_ForWalStreamWhenRoleCanSwitchWal_ReturnsSuccesson the same endpoint. - 1.5 Verify the backup-type gate with
Test_TestReplicationConnection_WhenRoleCannotSwitchWal_SucceedsForBackupTypesWithoutWalReplay: the same refusing credentials pass forFULLand forFULL_INCREMENTAL. Without this the change quietly blocks configurations that work. - 1.6 Verify the saved-database paths:
Test_TestDatabaseConnection_WhenTheSourceRevokedTheWalSwitchPrivilege_ReturnsNoWalSwitchPrivilegeCodeonPOST /databases/{id}/test-connection(controller.go:225), andTest_UpdateDatabase_RaisingToWalStreamWhenRoleCannotSwitchWal_ReturnsNoWalSwitchPrivilegeCodeproving a saved database cannot be raised toFULL_INCREMENTAL_WAL_STREAMagainst such a source, sinceUpdateDatabaseruns the same test (service.go:209). Create and update surface onlyError(), so the code carries a remedy sentence as itsMessageand the update test asserts that sentence. - 1.7 Update the Swagger annotations on both test-connection endpoints (
controller.go:216-224,:247-255) for the added failure, per the mandatory-Swagger rule inbackend/AGENTS.md. Verify withmake swaggerinbackend/that generation succeeds and both endpoints document the code.
2. Grant the ability during provisioning
- 2.1 Add
grantWalSwitchIfPermittedinforced_wal_rotation.goissuingGRANT EXECUTE ON FUNCTION pg_switch_wal()for the created role inside a savepoint, since a refused statement would abort the transaction that created the role, and call it from the provisioning transaction inCreateReplicationOnlyUser(model.go:723). Verify withTest_CreateReplicationOnlyUser_OnSelfManagedSource_GrantsForcedWalRotation, which asserts the created user passes a streaming connection test it could not pass without the grant, and drops the role int.Cleanup. - 2.2 Verify a refused grant does not fail provisioning:
Test_CreateReplicationOnlyUser_WhenTheSourceRefusesTheGrant_StillReturnsWorkingCredentialsprovisions as an administrator that may create roles and confer REPLICATION but owns nopg_catalogfunction, and asserts the returned credentials pass aFULL_INCREMENTALconnection test. - 2.3 Verify the grant reaches only the created role:
Test_CreateReplicationOnlyUser_ConfersForcedWalRotationOnTheCreatedRoleAloneasserts a second replication-only role on the same cluster still cannot executepg_switch_wal(), and that the created role gained no other attribute. - 2.4 Return
IsForcedWalRotationAvailablein aCreateReplicationOnlyUserResponseof its own, rather than on the sharedCreateReadOnlyUserResponsethe logical read-only user also uses, and update the Swagger annotations on that endpoint (controller.go:470-483). Verify withmake swaggerinbackend/that generation succeeds and the field appears in the generated spec.
3. Give the refusal its words in the interface
- 3.1 Add
ConnectionErrorCode.NoWalSwitchPrivilege = 'no_wal_switch_privilege'tofrontend/src/entity/databases/model/postgresql/physical/ConnectionErrorCode.tsand its content tophysicalConnectionErrorContent.ts: theGRANT EXECUTE ON FUNCTION pg_switch_wal()command step, a note offering full plus incremental as the other way out, and amanagedNotesaying RDS, Azure and GCP do not let a customer role confer it. The map is an exhaustiveRecordover the enum, so the compiler demands the entry. Verify withpnpm lintandpnpm buildinfrontend/. - 3.2 Show the provisioning result's
isForcedWalRotationAvailableinfrontend/src/features/databases/ui/edit/CreateReadOnlyComponent.tsx, the wizard step that provisions the user, so a managed-platform user learns at that moment that continuous WAL streaming will not be available with these credentials. Verify withpnpm lintandpnpm build. - 3.3 Keep the new copy English.
frontend/src/shared/i18n/does not exist on this branch, so the copy stays as literals, which the rootAGENTS.mdlanguage rule allows; the unmergedtranslate-frontend-uichange converts it along with the rest of the file. Verify withpnpm lint.
4. Close out
- 4.1 Run
make lintandmake testinbackend/, andpnpm lint,pnpm testandpnpm buildinfrontend/; fix every finding. On a Fedora host the suite is run withmake test-fedora, which supplies thelibedit.so.2shim the bundled MariaDB client needs; without it the MariaDB restore test fails for that reason alone. - 4.2 Run the
reviewersubagent over the working-tree diff and resolve every CHANGES REQUIRED finding. - 4.3 Put the upgrade note in the pull request description, since the repository keeps no changelog file: a saved
FULL_INCREMENTAL_WAL_STREAMdatabase whose credentials cannot force a segment switch keeps backing up but can no longer be saved from the edit form until the operator grants the privilege or lowers the backup type, and on RDS, Azure and GCP the privilege cannot be conferred at all. The symptom before this change waspermission denied for function pg_switch_walin the logs and a recovery point that only advanced when a segment filled. Verify the PR description contains it before requesting review.