Repository navigation
feat(postgres): expose standalone backups in GraphQL - #650
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Live-cluster validation remains pending, and fake-client tests cannot confirm deployed CRD/RBAC compatibility or asynchronous backup creation and destructive cleanup.
No open issues 🎉
5 files not reviewed
internal/graph/gengql/activitylog.generated.go: Generated fileinternal/graph/gengql/complexity.go: Generated fileinternal/graph/gengql/postgres_backup.generated.go: Generated fileinternal/graph/gengql/schema.generated.go: Generated fileinternal/graph/gengql/teams.generated.go: Generated file
What changed in this PR
Adds standalone Postgres backup management to Nais API’s GraphQL interface, keeping backups discoverable after their source database is deleted. Restore and export remain out of scope.
Changes:
- Adds backup lookup, filtered pagination, creation, and deletion with team authorization and activity logging.
- Adds supporting permissions, generated GraphQL bindings, and unit and integration coverage.
- Updates dependencies and writes point-in-time recovery settings to
spec.pitr.windowDayswhile preserving existing GraphQL fields and legacy fallback.
| File | Description |
|---|---|
| internal/persistence/postgres/queries.go | Writes PITR settings and uses shared identifier parsing. |
| internal/persistence/postgres/queries_test.go | Checks updates write the PITR window. |
| internal/persistence/postgres/node.go | Registers backup node identifiers. |
| internal/persistence/postgres/models.go | Updates the retention-bound comment to reference PITR. |
| internal/persistence/postgres/backup.go | Implements backup queries, mutations, validation, and status mapping. |
| internal/persistence/postgres/backup_test.go | Tests filtering, pagination, and public status conversion. |
| internal/persistence/postgres/backup_activitylog.go | Registers and records backup activity events. |
| internal/graph/schema/postgres_backup.graphqls | Defines the public backup API and activity types. |
| internal/graph/postgres_backup.resolvers.go | Connects GraphQL operations to backup logic. |
| internal/graph/gengql/teams.generated.go | Adds generated team-environment backup fields. |
| internal/graph/gengql/schema.generated.go | Adds generated mutation and node handling. |
| internal/graph/gengql/root_.generated.go | Updates embedded schema and generated API wiring. |
| internal/graph/gengql/postgres_backup.generated.go | Adds generated backup type bindings. |
| internal/graph/gengql/complexity.go | Accounts for backup pagination in query complexity. |
| internal/graph/gengql/activitylog.generated.go | Supports backup activity entries in GraphQL. |
| internal/database/migrations/0086_add_postgres_backup_authorizations.sql | Grants backup permissions to team members and owners. |
| internal/auth/authz/queries.go | Adds strict team authorization checks for backups. |
| integration_tests/postgres_backups.lua | Covers retained backups, access checks, mutations, and auditing. |
| integration_tests/k8s_resources/postgres_backups/dev/pg-crud-team/standalone.yaml | Supplies a completed backup fixture without its source database. |
| go.sum | Adds checksums for updated dependencies. |
| go.mod | Updates pgrator API and Kubernetes machinery dependencies. |
| charts/console-backend-rbac/templates/rbac.yaml | Grants backup resource access in both environment roles. |
| .configs/gqlgen.yaml | Maps BigInt to 64-bit integers for backup sizes. |
Review effort: Balanced
frodesundby
marked this pull request as ready for review
November 25, 2026 13:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TeamEnvironment.postgresBackupand paginatedpostgresBackups, with an optional filter on the source Postgres name. Backups remain discoverable after the source database is deleted.createPostgresBackupanddeletePostgresBackupwith team authorization and activity logging. Include the Kubernetes RBAC and authorization migration.spec.pitr.windowDayswhile retaining the existing GraphQL fields and legacy fallback.This builds on nais/pgrator#234. Restore and export are out of scope.
Verification
mise run testpassed, including integration coverage for listing and looking up backups after source deletion, authorization, creation, deletion, and activity logging.mise run fmt ::: generateleft the committed tree unchanged. Helm lint and lint of the new GraphQL schema passed.