Repository navigation
feat(postgres): set and show the point-in-time recovery window - #858
Merged
Merged
Conversation
Add --recovery-window-days (2-30) to postgres create and update, and show the window and earliest restore point in postgres get. Shortening the window warns that older backups are removed. Schema updated from the live API, which no longer has Postgres branch activity entries.
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.7.0 - 2026-11-23Full Changelog: v8.6.0...v8.7.0 🚀 Features
🐛 Bug Fixes
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Recovery-window range validation occurs after an API call, allowing authentication or discovery errors to mask invalid input rather than rejecting it before any API requests.
1 open issue
What changed in this PR
Adds Postgres point-in-time recovery window controls to the Nais CLI, complementing the API and Console support.
Changes:
- Adds
--recovery-window-daysto create and update, with range validation, comparison output, and warnings when shortening retention. - Shows the recovery window and earliest restore point in text and JSON output; clone behavior remains unchanged.
- Adds validation and output tests, refreshes the API schema and generated client, and removes obsolete branch activity fixtures.
| File | Description |
|---|---|
schema.graphql |
Adds retention fields and incorporates live API schema changes. |
internal/postgres/instance.go |
Preserves omission semantics for retention mutation inputs. |
internal/postgres/get.go |
Queries retention days and earliest restore time. |
internal/postgres/command/recovery_window_test.go |
Tests range validation and zero-as-unset behavior. |
internal/postgres/command/instance.go |
Wires retention into create/update and adds shortening warnings. |
internal/postgres/command/instance_update_test.go |
Tests retention changes, warnings, and invalid values. |
internal/postgres/command/get.go |
Displays recovery details in local time and UTC JSON. |
internal/postgres/command/get_test.go |
Checks recovery-window text and JSON output. |
internal/postgres/command/flag/flag.go |
Declares recovery-window flags and help text. |
internal/naisapi/gql/generated.go |
Regenerates client types and queries for the refreshed schema. |
internal/activity/activity_test.go |
Removes fixtures for retired branch activity types. |
Review effort: Balanced
frodesundby
added a commit
to nais/doc
that referenced
this pull request
Nov 23, 2026
Dokumenterer PITR-vinduet (`backupRetentionDays`) som nå kan settes i manifest, CLI og Console (nais/pgrator#225, #230, nais/api#639, nais/console-frontend#778, nais/cli#858). - Ny referanseside `reference/recovery-window.md`: område (2–30 dager), standard (2), hva som beholdes og slettes, hvor vinduet vises, og hvordan kostnadsestimatet i Console beregnes. - `how-to/create.md` og `how-to/manage.md`: nytt valg i manifest (`spec.backup.retentionDays`), CLI (`--recovery-window-days`) og Console, med advarsel om at forkorting sletter eldre backup permanent. - `README.md` og `reference/cloning.md`: lenker, og at en klon ikke arver kildens vindu. `reference/spec.md` er generert fra pgrator og allerede oppdatert. Bør ikke merges før CLI- og Console-PR-ene er ute i prod.
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.

Hvorfor
Nais API (nais/api#639) og Console (nais/console-frontend#778) lar brukere lese og sette PITR-vinduet (
backupRetentionDays). Dette er CLI-delen.Hva
nais postgres createognais postgres updatefår--recovery-window-days(2–30). Ugyldige verdier avvises før API-kall.updateviser gammel og ny verdi i sammenligningstabellen og advarer når vinduet forkortes, siden eldre backup da fjernes permanent.nais postgres getviser vinduet og tidligste gjenopprettingspunkt (lokal tid). JSON harrecoveryWindow.daysogrecoveryWindow.earliestRestorePoint(UTC).geti tekst og JSON.clone; en klon får plattformens standard (2 dager).Merk
schema.graphqler hentet fra live API og diffen er stor (277 linjer) siden prod har andre endringer siden sist. Branch-typene er borte (refactor(postgres): remove branches api#636), så de tre branch-oppføringene iTestPostgresActivityEntriesCanBeListeder fjernet.--recovery-window-days 0tolkes som ikke satt, som de andre tallflaggene.Ikke verifisert
Ikke kjørt mot ekte API, bare mot testserver.