catalog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 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 BackupNameAnnotation = "cnpg-backup-name"
View Source
const LatestTimelineId = -1

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"`
}

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) GetBackupIDs

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

GetBackupIDs returns the list of backup IDs in the catalog

func (*Catalog) GetBackupIdFromAnnotatedName

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

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"`
}

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"`
}

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"`
}

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"`
}

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"`
}

Jump to

Keyboard shortcuts

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