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
- Variables
- func Backup(ctx context.Context, kubeContext, namespace, stateDir string) error
- func HasBackup(stateDir string) bool
- func Restore(ctx context.Context, kubeContext, namespace, stateDir string) error
- func StateArchiveName() string
- func StateBranchName() string
- func WaitForReady(ctx context.Context, kubeContext, namespace string) error
Constants ¶
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" )
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 ¶
var Databases = []string{"ucp", "applications_rp", "dynamic_rp"}
Databases is the list of PostgreSQL databases that hold control-plane state.
Functions ¶
func HasBackup ¶
HasBackup reports whether a SQL dump exists for every database in the state directory.
func Restore ¶
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.
Types ¶
This section is empty.