backup

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackupFile used by a node to store its metadata
	BackupFile = "backup.json"
	// GlobalBackupFile used by coordinator to store its metadata
	GlobalBackupFile  = "backup_config.json"
	GlobalRestoreFile = "restore_config.json"
)
View Source
const Version = "1.0"

Version of backup structure

Variables

This section is empty.

Functions

This section is empty.

Types

type AbortRequest

type AbortRequest StatusRequest

type AbortResponse

type AbortResponse StatusResponse

type BackupBackendProvider

type BackupBackendProvider interface {
	BackupBackend(backend string) (modulecapabilities.BackupBackend, error)
}

type BackupRequest

type BackupRequest struct {
	// ID is the backup ID
	ID string
	// Backend specify on which backend to store backups (gcs, s3, ..)
	Backend string

	// Include is list of class which need to be backed up
	// The same class cannot appear in both Include and Exclude in the same request
	Include []string
	// Exclude means include all classes but those specified in Exclude
	// The same class cannot appear in both Include and Exclude in the same request
	Exclude []string
}

type CanCommitResponse

type CanCommitResponse struct {
	// Method is the backup operation (create, restore)
	Method Op
	// ID is the backup ID
	ID string
	// Timeout for how long the promise might be hold
	Timeout time.Duration
	// Err error
	Err string
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(
	logger logrus.FieldLogger,
	authorizer authorizer,
	schema schemaManger,
	sourcer Sourcer,
	backends BackupBackendProvider,
) *Manager

func (*Manager) Backup

func (*Manager) BackupStatus

func (m *Manager) BackupStatus(ctx context.Context, principal *models.Principal,
	backend, backupID string,
) (*models.BackupCreateStatusResponse, error)

func (*Manager) OnAbort

func (m *Manager) OnAbort(ctx context.Context, req *AbortRequest) error

OnAbort will be triggered when the coordinator abort the execution of a previous operation

func (*Manager) OnCanCommit

func (m *Manager) OnCanCommit(ctx context.Context, req *Request) *CanCommitResponse

OnCanCommit will be triggered when coordinator asks the node to participate in a distributed backup operation

func (*Manager) OnCommit

func (m *Manager) OnCommit(ctx context.Context, req *StatusRequest) (err error)

OnCommit will be triggered when the coordinator confirms the execution of a previous operation

func (*Manager) OnStatus

func (m *Manager) OnStatus(ctx context.Context, req *StatusRequest) *StatusResponse

func (*Manager) RestorationStatus

func (m *Manager) RestorationStatus(ctx context.Context, principal *models.Principal, backend, ID string,
) (_ Status, err error)

func (*Manager) Restore

type Op

type Op string

Op is the kind of a backup operation

const (
	OpCreate  Op = "create"
	OpRestore Op = "restore"
)

type Request

type Request struct {
	// Method is the backup operation (create, restore)
	Method Op
	// ID is the backup ID
	ID string
	// Backend specify on which backend to store backups (gcs, s3, ..)
	Backend string

	// Classes is list of class which need to be backed up
	Classes []string

	// Duration
	Duration time.Duration
}

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler assigns backup operations to coordinators.

func NewScheduler

func NewScheduler(
	authorizer authorizer,
	client client,
	sourcer selector,
	backends BackupBackendProvider,
	nodeResolver nodeResolver,
	logger logrus.FieldLogger,
) *Scheduler

NewScheduler creates a new scheduler with two coordinators

func (*Scheduler) Backup

func (s *Scheduler) Backup(ctx context.Context, pr *models.Principal, req *BackupRequest,
) (_ *models.BackupCreateResponse, err error)

func (*Scheduler) BackupStatus

func (s *Scheduler) BackupStatus(ctx context.Context, principal *models.Principal,
	backend, backupID string,
) (_ *Status, err error)

func (*Scheduler) RestorationStatus

func (s *Scheduler) RestorationStatus(ctx context.Context, principal *models.Principal, backend, backupID string,
) (_ *Status, err error)

func (*Scheduler) Restore

func (s *Scheduler) Restore(ctx context.Context, pr *models.Principal,
	req *BackupRequest,
) (_ *models.BackupRestoreResponse, err error)

type Sourcer

type Sourcer interface {
	// ReleaseBackup signals to the underlying index that the files have been
	// copied (or the operation aborted), and that it is safe for the index to
	// change the files, such as start compactions.
	ReleaseBackup(_ context.Context, id, class string) error

	// Backupable returns whether all given class can be backed up.
	Backupable(_ context.Context, classes []string) error

	// BackupDescriptors returns a channel of class descriptors.
	// Class descriptor records everything needed to restore a class
	// If an error happens a descriptor with an error will be written to the channel just before closing it.
	//
	// BackupDescriptors acquires resources so that a call to ReleaseBackup() is mandatory to free acquired resources.
	BackupDescriptors(_ context.Context, bakid string, classes []string,
	) <-chan backup.ClassDescriptor

	// ClassExists checks whether a class exits or not
	ClassExists(name string) bool

	// ListBackupable returns a list of all classes which can be backed up.
	//
	// A class cannot be backed up either if it doesn't exist or if it has more than one physical shard.
	ListBackupable() []string
}

Sourcer represents the source of artifacts used in the backup

type Status

type Status struct {
	Path        string
	StartedAt   time.Time
	CompletedAt time.Time
	Status      backup.Status
	Err         string
}

type StatusRequest

type StatusRequest struct {
	// Method is the backup operation (create, restore)
	Method Op
	// ID is the backup ID
	ID string
	// Backend specify on which backend to store backups (gcs, s3, ..)
	Backend string
}

type StatusResponse

type StatusResponse struct {
	// Method is the backup operation (create, restore)
	Method Op
	ID     string
	Status backup.Status
	Err    string
}

Jump to

Keyboard shortcuts

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