backup

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 37 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AWSAccessKeySecretKey            = "AWS_ACCESS_KEY_ID"
	AWSSecretAccessKeySecretKey      = "AWS_SECRET_ACCESS_KEY"
	AzureStorageAccountNameSecretKey = "AZURE_STORAGE_ACCOUNT_NAME"
	AzureStorageAccountKeySecretKey  = "AZURE_STORAGE_ACCOUNT_KEY"
	SSECustomerKey                   = "SSE_CUSTOMER_KEY"
	KMSKeyID                         = "KMS_KEY_ID"
)

Variables

View Source
var ErrNoOplogsForPITR = errors.New("there is no oplogs that can cover the date/time or no oplogs at all")

Functions

func BackupFromTask added in v1.13.0

func GetPBMConfig added in v1.14.0

func GetPBMConfig(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB, stg api.BackupStorageSpec) (config.Config, error)

GetPBMConfig returns PBM configuration with given storage.

func GetPBMProfile added in v1.20.0

func GetPBMProfile(
	ctx context.Context,
	k8sclient client.Client,
	cluster *api.PerconaServerMongoDB,
	name string,
	stg api.BackupStorageSpec,
) (config.Config, error)

func GetPBMStorageAzureConfig added in v1.20.0

func GetPBMStorageAzureConfig(
	ctx context.Context,
	k8sclient client.Client,
	cluster *api.PerconaServerMongoDB,
	stg api.BackupStorageSpec,
) (config.StorageConf, error)

func GetPBMStorageConfig added in v1.20.0

func GetPBMStorageConfig(
	ctx context.Context,
	k8sclient client.Client,
	cluster *api.PerconaServerMongoDB,
	stg api.BackupStorageSpec,
) (config.StorageConf, error)

func GetPBMStorageS3Config added in v1.20.0

func GetPBMStorageS3Config(
	ctx context.Context,
	k8sclient client.Client,
	cluster *api.PerconaServerMongoDB,
	stg api.BackupStorageSpec,
) (config.StorageConf, error)

func GetPriorities added in v1.14.0

func GetPriorities(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB) (map[string]float64, error)

GetPriorities returns priorities to be used in PBM config.

func HasActiveJobs added in v1.4.0

func HasActiveJobs(ctx context.Context, newPBMFunc NewPBMFunc, cl client.Client, cluster *api.PerconaServerMongoDB, current Job, allowLock ...LockHeaderPredicate) (bool, error)

HasActiveJobs returns true if there are running backups or restores in given cluster and namespace

func IsErrNoDocuments added in v1.20.0

func IsErrNoDocuments(err error) bool

func IsPBMNotConfiguredError added in v1.16.0

func IsPBMNotConfiguredError(err error) bool

func IsPITRLock added in v1.8.0

func IsPITRLock(l lock.LockHeader) bool

func IsResync added in v1.20.0

func IsResync(l lock.LockHeader) bool

func NotPITRLock added in v1.8.0

func NotPITRLock(l lock.LockHeader) bool

func ResyncConfigExec added in v1.20.0

func ResyncConfigExec(ctx context.Context, cl *clientcmd.Client, pod *corev1.Pod) error

Types

type BackupMeta added in v1.16.0

type BackupMeta = backup.BackupMeta

type Job added in v1.4.0

type Job struct {
	Name string
	Type JobType
}

func NewBackupJob added in v1.8.0

func NewBackupJob(name string) Job

type JobType added in v1.4.0

type JobType int
const (
	TypeBackup JobType = iota
	TypeRestore
	TypePITRestore
)

type LockHeaderPredicate added in v1.8.0

type LockHeaderPredicate func(lock.LockHeader) bool

func NotJobLock added in v1.8.0

func NotJobLock(j Job) LockHeaderPredicate

type NewPBMFunc added in v1.15.0

type NewPBMFunc func(ctx context.Context, c client.Client, cluster *api.PerconaServerMongoDB) (PBM, error)

type PBM added in v1.4.0

type PBM interface {
	Conn() *mongo.Client

	GetPITRChunkContains(ctx context.Context, unixTS int64) (*oplog.OplogChunk, error)
	GetLatestTimelinePITR(ctx context.Context) (oplog.Timeline, error)
	PITRGetChunksSlice(ctx context.Context, rs string, from, to primitive.Timestamp) ([]oplog.OplogChunk, error)
	PITRChunksCollection() *mongo.Collection

	Logger() pbmLog.Logger
	GetStorage(ctx context.Context, e pbmLog.LogEvent) (storage.Storage, error)
	SendCmd(ctx context.Context, cmd ctrl.Cmd) error
	Close(ctx context.Context) error
	HasLocks(ctx context.Context, predicates ...LockHeaderPredicate) (bool, error)
	ValidateBackup(ctx context.Context, cfg *config.Config, bcp *psmdbv1.PerconaServerMongoDBBackup) error

	ResyncMainStorage(ctx context.Context) error
	ResyncMainStorageAndWait(ctx context.Context) error
	ResyncProfile(ctx context.Context, name string) error
	ResyncProfileAndWait(ctx context.Context, name string) error

	GetBackupMeta(ctx context.Context, bcpName string) (*backup.BackupMeta, error)
	GetRestoreMeta(ctx context.Context, name string) (*restore.RestoreMeta, error)

	DeleteBackup(ctx context.Context, name string) error

	AddProfile(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB, name string, stg api.BackupStorageSpec) error
	GetProfile(ctx context.Context, name string) (*config.Config, error)
	RemoveProfile(ctx context.Context, name string) error
	GetNSetConfig(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB) error
	GetNSetConfigLegacy(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB, stg api.BackupStorageSpec) error
	SetConfig(ctx context.Context, cfg *config.Config) error
	SetConfigVar(ctx context.Context, key, val string) error

	GetConfig(ctx context.Context) (*config.Config, error)
	GetConfigVar(ctx context.Context, key string) (any, error)

	DeletePITRChunks(ctx context.Context, until primitive.Timestamp) error

	Node(ctx context.Context) (string, error)
}

func NewPBM added in v1.4.0

func NewPBM(ctx context.Context, c client.Client, cluster *api.PerconaServerMongoDB) (PBM, error)

NewPBM creates a new connection to PBM. It should be closed after the last use with.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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