Skip to content

feat(postgres): expose standalone backups in GraphQL - #650

Merged
frodesundby merged 6 commits into
mainfrom
feat/postgres-backups-graphql
Nov 25, 2026
Merged

frodesundby merged 6 commits into
mainfrom
feat/postgres-backups-graphql

Conversation

@frodesundby

Copy link
Copy Markdown
Contributor

What

  • Add TeamEnvironment.postgresBackup and paginated postgresBackups, with an optional filter on the source Postgres name. Backups remain discoverable after the source database is deleted.
  • Add createPostgresBackup and deletePostgresBackup with team authorization and activity logging. Include the Kubernetes RBAC and authorization migration.
  • Update the pgrator API dependency and write PITR changes to spec.pitr.windowDays while retaining the existing GraphQL fields and legacy fallback.

This builds on nais/pgrator#234. Restore and export are out of scope.

Verification

  • mise run test passed, including integration coverage for listing and looking up backups after source deletion, authorization, creation, deletion, and activity logging.
  • mise run fmt ::: generate left the committed tree unchanged. Helm lint and lint of the new GraphQL schema passed.
  • Dev validation pending: look up an existing backup and exercise creation and deletion of a new one.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 file
  • internal/graph/gengql/complexity.go: Generated file
  • internal/graph/gengql/postgres_backup.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
  • internal/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.windowDays while 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
frodesundby marked this pull request as ready for review November 25, 2026 13:45
@frodesundby
frodesundby requested a review from a team as a code owner November 25, 2026 13:45

@christeredvartsen christeredvartsen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@frodesundby
frodesundby merged commit 1481592 into main Nov 25, 2026
10 checks passed
@frodesundby
frodesundby deleted the feat/postgres-backups-graphql branch November 25, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants