Repository navigation
feat(postgres): add clone command for point-in-time recovery - #855
Merged
Merged
Conversation
nais postgres clone <source> <name> creates a new database from the source's backups in the same team and environment. The source is not changed and no applications are moved. --at selects the point in time, as a local time like "2026-11-16 12:00" or RFC 3339 with an offset. Without it the clone is made from the latest available point, 10 minutes ago, to stay inside archived WAL. A local time skipped by a daylight saving change is rejected and a repeated one resolves to its earlier occurrence. PostgreSQL version and extensions come from the source. High availability, CPU, memory and disk default to the source's and can be overridden; the disk cannot be smaller than the source's. get now reports the clone source, point and status. Update the GraphQL schema from the live API.
Contributor
📝 Changelog previewBelow is a preview of the Changelog that will be added to the next release. Only commit messages that follow the Conventional Commits specification will be included in the Changelog. v8.6.0 - 2026-11-18Full Changelog: v8.5.0...v8.6.0 🚀 Features
🐛 Bug Fixes
|
frodesundby
force-pushed
the
feat/postgres-clone
branch
from
November 18, 2026 08:18
ed3bc1f to
94e7132
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The daylight-saving overlap check assumes a one-hour rollback, causing half-hour transitions to select a recovery point 30 minutes later than promised.
1 open issue
What changed in this PR
Adds nais postgres clone <source> <name> for point-in-time recovery using the existing creation mutation. Clones remain in the source’s team and environment without changing the source or moving applications.
Changes:
- Adds optional recovery-time selection, backup-window validation, configuration overrides, and confirmation.
- Extends
postgres getwith recovery origin, time, and progress in human-readable and JSON output. - Updates the GraphQL schema and generated client, with tests for cloning and recovery output.
| File | Description |
|---|---|
schema.graphql |
Adds recovery types and refreshes cost and vulnerability fields. |
internal/postgres/instance.go |
Makes recovery input optional in the creation mutation. |
internal/postgres/get.go |
Queries recovery metadata. |
internal/postgres/command/postgres.go |
Registers the clone command. |
internal/postgres/command/get.go |
Displays recovery details in text and JSON. |
internal/postgres/command/flag/flag.go |
Defines recovery-time and configuration flags. |
internal/postgres/command/clone.go |
Implements cloning, time parsing, validation, and confirmation. |
internal/postgres/command/clone_test.go |
Tests parsing, validation, mutation inputs, and recovery output. |
internal/postgres/clone.go |
Fetches source configuration and backup-window metadata. |
internal/naisapi/gql/generated.go |
Generates client support for recovery inputs and queries. |
Review effort: Balanced
…ffsets The overlap check assumed every clock change is one hour, so a half-hour change such as Australia/Lord_Howe resolved a repeated time to the later occurrence. Enumerate the offsets in effect around the date instead; a time that no offset produces does not exist, and a repeated one resolves to the earliest instant. Cover half-hour repeats and gaps.
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.

Summary
Adds
nais postgres clone <source> <name>, which creates a new Postgres from the backups of an existing one in the same team and environment. The source is not changed and no applications are moved to the clone.--atis optional. A local time like"2026-11-16 12:00"or RFC 3339 with an offset is accepted, in whole seconds and not in the future. Without it the clone is made from now minus 10 minutes, to stay inside archived WAL.--high-availability,--cpu,--memoryand--disk-size. The disk cannot be smaller than the source's (enforced by the API).nais postgres getnow showsCloned from,Clone pointandClone status, and arecoveryobject in JSON (UTC).schema.graphqlis updated from the live API, which also pulls in unrelatedPostgresCostandImageVulnerabilityFacets.It uses the existing
createPostgresmutation with the optionalrecovery { sourcePostgres, targetTime }input, so no API or operator changes are needed.createis unchanged.Testing
getoutput.mise run testandmise run checkpass.frogresin nav-dev (nais,dev-gcp) with the default point, now − 1 minute and now − 5 seconds. All three clones completed and were deleted afterwards.Not verified