catalog

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package catalog is the implementation of a backup catalog

Index

Constants

View Source
const (
	// LatestTimelineID is used to mark the "latest" timeline option
	LatestTimelineID = -1
	// BackupNameAnnotation is used to add CNPG backup name to the pgBackRest backup's
	// metadata as an annotation. This makes it possible to trace specific backup to
	// a Backup resource.
	BackupNameAnnotation = "cnpg-backup-name"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	Archive    []PgbackrestWALArchive     `json:"archive"`
	Backups    []PgbackrestBackup         `json:"backup"`
	Stanza     string                     `json:"name"`
	Databases  []PgbackrestBackupDatabase `json:"db"`
	Encryption string                     `json:"cipher"`
}

Catalog represents a catalog of archive and backup storages of a specific stanza

func NewCatalogFromPgbackrestInfo

func NewCatalogFromPgbackrestInfo(rawJSON string) (*Catalog, error)

NewCatalogFromPgbackrestInfo parses the output of pgbackrest info

func NewSingleBackupCatalogFromPgbackrestInfo

func NewSingleBackupCatalogFromPgbackrestInfo(rawJSON string) (*Catalog, error)

NewSingleBackupCatalogFromPgbackrestInfo parses the output of pgbackrest info targeting a single backup via "--set". While structure is the same as for the full backups list there is only a single backup in the list but with additional fields included.

func (*Catalog) FindBackupInfo

func (catalog *Catalog) FindBackupInfo(
	recoveryTarget recoveryTargetAdapter,
) (*PgbackrestBackup, error)

FindBackupInfo finds the backup info that should be used to file a PITR request via target parameters specified within `RecoveryTarget`

func (*Catalog) FirstRecoverabilityPoint

func (catalog *Catalog) FirstRecoverabilityPoint() *time.Time

FirstRecoverabilityPoint gets the start time of the first backup in the catalog

func (*Catalog) GetBackupIDFromAnnotatedName added in v0.1.1

func (catalog *Catalog) GetBackupIDFromAnnotatedName(backupName string) string

GetBackupIDFromAnnotatedName returns the ID of the backup with the custom CNPG annotation set to the provided name.

func (*Catalog) GetBackupIDs

func (catalog *Catalog) GetBackupIDs() []string

GetBackupIDs returns the list of backup IDs in the catalog

func (Catalog) GetBackupMethod

func (catalog Catalog) GetBackupMethod() string

GetBackupMethod returns the backup method

func (*Catalog) GetFirstRecoverabilityPoint

func (catalog *Catalog) GetFirstRecoverabilityPoint() *time.Time

GetFirstRecoverabilityPoint see FirstRecoverabilityPoint. This is needed to adhere to the common backup interface.

func (*Catalog) GetLastSuccessfulBackupTime

func (catalog *Catalog) GetLastSuccessfulBackupTime() *time.Time

GetLastSuccessfulBackupTime gets the end time of the last successful backup or nil if no backup was successful

func (*Catalog) LatestBackupInfo

func (catalog *Catalog) LatestBackupInfo() *PgbackrestBackup

LatestBackupInfo gets the information about the latest successful backup

type PgbackrestBackup

type PgbackrestBackup struct {
	Annotations map[string]string `json:"annotation,omitempty"`

	Time PgbackrestBackupTime       `json:"timestamp"`
	WAL  PgbackrestBackupWALArchive `json:"archive"`
	LSN  PgbackrestBackupLSN        `json:"lsn"`

	// The ID of the backup - reusing pgbackrest's label
	ID string `json:"label"`
	// The ID of the previous backup for incremental and differential backups
	Prior string `json:"prior,omitempty"`

	// Backup type
	Type string `json:"type"`
}

PgbackrestBackup represent a backup as created by pgbackrest

type PgbackrestBackupDatabase

type PgbackrestBackupDatabase struct {
	ID       int    `json:"id"`
	RepoKey  int    `json:"repo_key"`
	SystemID int64  `json:"system-id,omitempty"`
	Version  string `json:"version,omitempty"`
}

PgbackrestBackupDatabase contains identifying metadata of the database in the stanza

type PgbackrestBackupLSN

type PgbackrestBackupLSN struct {
	// The LSN where the backup started
	Start string `json:"start"`
	// The LSN where the backup ended
	Stop string `json:"stop"`
}

PgbackrestBackupLSN represents an LSN range the backup contains

type PgbackrestBackupTime

type PgbackrestBackupTime struct {
	// The moment where the backup started
	Start int64 `json:"start"`

	// The moment where the backup ended
	Stop int64 `json:"stop"`
}

PgbackrestBackupTime represents a time span of the creation of a single backup

type PgbackrestBackupWALArchive

type PgbackrestBackupWALArchive struct {
	// The WAL where the backup started
	Start string `json:"start"`
	// The WAL where the backup ended
	Stop string `json:"stop"`
}

PgbackrestBackupWALArchive represents a WAL archive range the backup contains

type PgbackrestWALArchive

type PgbackrestWALArchive struct {
	ID string `json:"id"`
	// First WAL in the archive
	Min string `json:"min"`
	// Last WAL in the archive
	Max      string                   `json:"max"`
	Database PgbackrestBackupDatabase `json:"database"`
}

PgbackrestWALArchive represents a pgBackRest WAL archive for a specific database

Jump to

Keyboard shortcuts

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