Documentation
¶
Overview ¶
Package command contains the utilities to interact with pgbackrest.
This package is able to download the backup catalog, given an object store, and to find the required backup to recreate a cluster, given a certain point in time. It can also delete backups according to pgbackrest object store configuration and retention policies, and find the latest successful backup. This is useful to recovery from the last consistent state.
A backup catalog is represented by the Catalog structure, and can be created using the NewCatalog function or by downloading it from an object store via GetBackupList. A backup catalog is just a sorted list of BackupInfo objects.
We also have features to gather all the environment variables required for the pgbackrest utilities to work correctly.
The functions which call the pgbackrest utilities (such as GetBackupList) require the environment variables to be passed, and the calling code is supposed gather them (i.e. via the EnvSetCloudCredentials) before calling them. A Kubernetes client is required to get the environment variables, as we need to download the content from the required secrets, but is not required to call pgbackrest.
Index ¶
- func AppendCloudProviderOptionsFromConfiguration(ctx context.Context, options []string, ...) (resOptions []string, err error)
- func AppendLogOptionsFromConfiguration(ctx context.Context, options []string, ...) (resOptions []string, err error)
- func AppendRetentionOptionsFromConfiguration(ctx context.Context, options []string, ...) (resOptions []string, err error)
- func AppendStanzaOptionsFromConfiguration(ctx context.Context, options []string, ...) (resOptions []string, err error)
- func CloudWalRestoreOptions(ctx context.Context, configuration *pgbackrestApi.PgbackrestConfiguration, ...) ([]string, error)
- func GetBackupByAnnotatedName(ctx context.Context, backupName string, stanza string, ...) (*catalog.Catalog, error)
- func GetBackupList(ctx context.Context, ...) (*catalog.Catalog, error)
- func GetLatestBackup(ctx context.Context, stanza string, ...) (*catalog.PgbackrestBackup, error)
- func UnmarshalPgbackrestRestoreExitCode(_ context.Context, exitCode int) error
- type CloudRestoreError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendCloudProviderOptionsFromConfiguration ¶
func AppendCloudProviderOptionsFromConfiguration( ctx context.Context, options []string, configuration *pgbackrestApi.PgbackrestConfiguration, ) (resOptions []string, err error)
AppendCloudProviderOptionsFromConfiguration takes an options array and adds the cloud provider specified in the pgbackrest configuration object
func AppendLogOptionsFromConfiguration ¶
func AppendLogOptionsFromConfiguration( ctx context.Context, options []string, configuration *pgbackrestApi.PgbackrestConfiguration, ) (resOptions []string, err error)
AppendLogOptionsFromConfiguration takes an options array and adds the necessary stanza-specific options required for all operations connecting to the database
func AppendRetentionOptionsFromConfiguration ¶
func AppendRetentionOptionsFromConfiguration( ctx context.Context, options []string, configuration *pgbackrestApi.PgbackrestConfiguration, ) (resOptions []string, err error)
AppendRetentionOptionsFromConfiguration takes an options array and adds the retention options specified in the pgbackrest configuration object for each repository
func AppendStanzaOptionsFromConfiguration ¶
func AppendStanzaOptionsFromConfiguration( ctx context.Context, options []string, configuration *pgbackrestApi.PgbackrestConfiguration, pgDataDirectory string, clusterRunning bool, ) (resOptions []string, err error)
AppendStanzaOptionsFromConfiguration takes an options array and adds the necessary stanza-specific options required for all operations connecting to the database
func CloudWalRestoreOptions ¶
func CloudWalRestoreOptions( ctx context.Context, configuration *pgbackrestApi.PgbackrestConfiguration, clusterName string, pgDataDirectory string, ) ([]string, error)
CloudWalRestoreOptions returns the options needed to execute the pgbackrest command successfully
func GetBackupByAnnotatedName ¶
func GetBackupByAnnotatedName( ctx context.Context, backupName string, stanza string, pgbackrestConfiguration *pgbackrestApi.PgbackrestConfiguration, env []string, ) (*catalog.Catalog, error)
GetBackupByAnnotatedName uses a name stored in an annotation to retrieve the backup. That's not something supported natively so all backups must be retrieved first.
func GetBackupList ¶
func GetBackupList( ctx context.Context, pgbackrestConfiguration *pgbackrestApi.PgbackrestConfiguration, stanza string, env []string, ) (*catalog.Catalog, error)
GetBackupList returns the catalog reading it from the object store
func GetLatestBackup ¶
func GetLatestBackup( ctx context.Context, stanza string, pgbackrestConfiguration *pgbackrestApi.PgbackrestConfiguration, env []string, ) (*catalog.PgbackrestBackup, error)
GetLatestBackup returns the latest executed backup
Types ¶
type CloudRestoreError ¶
type CloudRestoreError struct {
// The exit code returned by pgbackrest
ExitCode int
// This is true when pgbackrest can return significant error codes
HasRestoreErrorCodes bool
}
CloudRestoreError is raised when pgbackrest restore fails
func (*CloudRestoreError) Error ¶
func (err *CloudRestoreError) Error() string
Error implements the error interface
func (*CloudRestoreError) IsRetriable ¶
func (err *CloudRestoreError) IsRetriable() bool
IsRetriable returns true whether the error is temporary, and it could be a good idea to retry the restore later