command

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Overview

Package command contains the utilities to interact with barman-cloud.

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 barman object store configuration and retention policies, and find the latest successful backup. This is useful to recovery from the last consistent state. We detect the possible commands to be executed, fulfilling the barman capabilities, and define an interface for building commands.

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 barman-cloud utilities to work correctly.

The functions which call the barman-cloud 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 barman-cloud.

Package command contains

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCloudProviderOptionsFromBackup

func AppendCloudProviderOptionsFromBackup(
	ctx context.Context,
	options []string,
	credentials barmanApi.BarmanCredentials,
) ([]string, error)

AppendCloudProviderOptionsFromBackup takes an options array and adds the cloud provider specified in the Backup object

func AppendCloudProviderOptionsFromConfiguration

func AppendCloudProviderOptionsFromConfiguration(
	ctx context.Context,
	options []string,
	barmanConfiguration *barmanApi.BarmanObjectStoreConfiguration,
) ([]string, error)

AppendCloudProviderOptionsFromConfiguration takes an options array and adds the cloud provider specified in the Barman configuration object

func CloudWalRestoreOptions

func CloudWalRestoreOptions(
	ctx context.Context,
	configuration *barmanApi.BarmanObjectStoreConfiguration,
	clusterName string,
) ([]string, error)

CloudWalRestoreOptions returns the options needed to execute the barman command successfully

func ContextWithDefaultAzureCredentials

func ContextWithDefaultAzureCredentials(ctx context.Context, enabled bool) context.Context

ContextWithDefaultAzureCredentials create a context that contains the contextKeyUseDefaultAzureCredentials flag. When set to true barman-cloud will use the default Azure credentials.

func DeleteBackupsByPolicy

func DeleteBackupsByPolicy(
	ctx context.Context,
	barmanConfiguration *barmanApi.BarmanObjectStoreConfiguration,
	serverName string,
	env []string,
	retentionPolicy string,
) error

DeleteBackupsByPolicy executes a command that deletes backups, given the Barman object store configuration, the retention policies, the server name and the environment variables

func GetBackupByName

func GetBackupByName(
	ctx context.Context,
	backupName string,
	serverName string,
	barmanConfiguration *barmanApi.BarmanObjectStoreConfiguration,
	env []string,
) (*catalog.BarmanBackup, error)

GetBackupByName returns the backup data found for a given backup

func GetBackupList

func GetBackupList(
	ctx context.Context,
	barmanConfiguration *barmanApi.BarmanObjectStoreConfiguration,
	serverName string,
	env []string,
) (*catalog.Catalog, error)

GetBackupList returns the catalog reading it from the object store

func GetLatestBackup

func GetLatestBackup(
	ctx context.Context,
	serverName string,
	barmanConfiguration *barmanApi.BarmanObjectStoreConfiguration,
	env []string,
) (*catalog.BarmanBackup, error)

GetLatestBackup returns the latest executed backup

func UnmarshalBarmanCloudRestoreExitCode

func UnmarshalBarmanCloudRestoreExitCode(exitCode int) error

UnmarshalBarmanCloudRestoreExitCode returns the correct error for a certain barman-cloud-restore exit code

Types

type CloudRestoreError

type CloudRestoreError struct {
	// The exit code returned by Barman
	ExitCode int
}

CloudRestoreError is raised when barman-cloud-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

Jump to

Keyboard shortcuts

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