pgbackup

package
v0.60.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pgbackup backs up and restores the Radius control-plane PostgreSQL databases.

The Radius control plane stores resource data and deployment history in three logical PostgreSQL databases (ucp, applications_rp, dynamic_rp) served by a single in-cluster PostgreSQL instance. When the control plane runs on an ephemeral cluster, that data is lost on teardown. This package dumps each database to a plain SQL file (via "kubectl exec ... pg_dump") and restores them (via "kubectl exec ... psql") so state survives across runs.

Index

Constants

View Source
const (
	// DefaultNamespace is the Kubernetes namespace where Radius (and its PostgreSQL instance)
	// is installed.
	DefaultNamespace = "radius-system"

	// PodLabelSelector is the label selector for the PostgreSQL pod deployed by the Helm chart.
	PodLabelSelector = "app.kubernetes.io/name=database"

	// PostgresUser is the superuser used for backup/restore operations. It can read and write
	// every logical database regardless of which per-RP user owns the data.
	PostgresUser = "radius"
)
View Source
const (
	// DefaultStateArchive is the default archive name where durable Radius state is committed:
	// the PostgreSQL dumps produced by this package and the Terraform state Secrets exported by
	// pkg/cli/tfstate. It is shared by the "rad shutdown" and "rad startup" commands.
	DefaultStateArchive = "radius-state"

	// StateArchiveEnvVar overrides DefaultStateArchive. It lets parallel tests use isolated
	// archives without colliding.
	StateArchiveEnvVar = "RADIUS_STATE_ARCHIVE"

	// DefaultStateBranch is deprecated. Use DefaultStateArchive.
	DefaultStateBranch = DefaultStateArchive

	// StateBranchEnvVar is deprecated. Use StateArchiveEnvVar.
	StateBranchEnvVar = "RADIUS_STATE_BRANCH"
)

Variables

View Source
var Databases = []string{"ucp", "applications_rp", "dynamic_rp"}

Databases is the list of PostgreSQL databases that hold control-plane state.

Functions

func Backup

func Backup(ctx context.Context, kubeContext, namespace, stateDir string) error

Backup dumps each PostgreSQL database to a plain SQL file in the state directory.

func HasBackup

func HasBackup(stateDir string) bool

HasBackup reports whether a SQL dump exists for every database in the state directory.

func Restore

func Restore(ctx context.Context, kubeContext, namespace, stateDir string) error

Restore loads each SQL dump from the state directory into its PostgreSQL database. The dumps are produced with --clean --if-exists, so restore is idempotent.

func StateArchiveName

func StateArchiveName() string

StateArchiveName returns the state archive name, honoring StateArchiveEnvVar, then the deprecated StateBranchEnvVar, and falling back to DefaultStateArchive.

func StateBranchName

func StateBranchName() string

StateBranchName is deprecated. Use StateArchiveName.

func WaitForReady

func WaitForReady(ctx context.Context, kubeContext, namespace string) error

WaitForReady blocks until the PostgreSQL pod reports ready, using "kubectl wait".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL