Documentation
¶
Overview ¶
Package catalog is the implementation of a backup catalog
Index ¶
- Constants
- type Catalog
- func (catalog *Catalog) DescribesRepositories(repositories int) bool
- func (catalog *Catalog) FindBackupInfo(recoveryTarget recoveryTargetAdapter) (*PgbackrestBackup, error)
- func (catalog *Catalog) FirstRecoverabilityPoint() *time.Time
- func (catalog *Catalog) GetBackupIDFromAnnotatedName(backupName string) string
- func (catalog *Catalog) GetBackupIDs() []string
- func (catalog Catalog) GetBackupMethod() string
- func (catalog *Catalog) GetFirstRecoverabilityPoint() *time.Time
- func (catalog *Catalog) GetLastSuccessfulBackupTime() *time.Time
- func (catalog *Catalog) LatestBackupInfo() *PgbackrestBackup
- func (catalog *Catalog) StanzaMissing() bool
- type PgbackrestBackup
- type PgbackrestBackupDatabase
- type PgbackrestBackupLSN
- type PgbackrestBackupTime
- type PgbackrestBackupWALArchive
- type PgbackrestRepo
- type PgbackrestStanzaStatus
- type PgbackrestWALArchive
Constants ¶
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" )
const ( // StanzaStatusCodeOk means everything that was asked about could be read and is consistent. StanzaStatusCodeOk = 0 // StanzaStatusCodeMissing means the stanza has not been created in the repository yet // (its archive.info is absent); WAL archiving cannot succeed until stanza-create runs. StanzaStatusCodeMissing = 1 // StanzaStatusCodeNoBackup means the repository could be read in full and holds no backup yet. StanzaStatusCodeNoBackup = 2 // StanzaStatusCodeMixed means the repositories of the stanza do not all report the same // status. With one repository holding backups and another still empty this is the // expected answer, so it says nothing about any repository having failed. StanzaStatusCodeMixed = 4 )
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"`
Status PgbackrestStanzaStatus `json:"status"`
Repos []PgbackrestRepo `json:"repo"`
}
Catalog represents a catalog of archive and backup storages of a specific stanza
func NewCatalogFromPgbackrestInfo ¶
NewCatalogFromPgbackrestInfo parses the output of pgbackrest info
func NewSingleBackupCatalogFromPgbackrestInfo ¶
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) DescribesRepositories ¶ added in v0.10.0
DescribesRepositories reports whether the catalog is a complete and consistent description of the given number of repositories — what a caller needs before concluding that a backup absent from it does not exist anymore.
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 ¶
FirstRecoverabilityPoint gets the start time of the first backup in the catalog
func (*Catalog) GetBackupIDFromAnnotatedName ¶ added in v0.1.1
GetBackupIDFromAnnotatedName returns the ID of the backup with the custom CNPG annotation set to the provided name.
func (*Catalog) GetBackupIDs ¶
GetBackupIDs returns the list of backup IDs in the catalog
func (Catalog) GetBackupMethod ¶
GetBackupMethod returns the backup method
func (*Catalog) GetFirstRecoverabilityPoint ¶
GetFirstRecoverabilityPoint see FirstRecoverabilityPoint. This is needed to adhere to the common backup interface.
func (*Catalog) GetLastSuccessfulBackupTime ¶
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
func (*Catalog) StanzaMissing ¶ added in v0.7.0
StanzaMissing reports whether "pgbackrest info" says the stanza has not been created in the repository yet, i.e. WAL archiving cannot work until stanza-create is run.
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 PgbackrestRepo ¶ added in v0.10.0
type PgbackrestRepo struct {
// The one-based index of the repository in the pgbackrest configuration
Key int `json:"key"`
// "pgbackrest info" does not fail when one repository cannot be read: it reports the
// failure here and still returns what the other repositories hold.
Status PgbackrestStanzaStatus `json:"status"`
}
PgbackrestRepo is one of the repositories of a stanza, as "pgbackrest info" reports it. Only the fields we act on are parsed.
type PgbackrestStanzaStatus ¶ added in v0.7.0
PgbackrestStanzaStatus is the "status" object that "pgbackrest info" reports for a stanza. Only the fields we act on are parsed; the rest of the object is ignored.
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