backup

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotExist

func IsNotExist(err error) bool

IsNotExist returns true if the error represents a object access against a objects that does not exist

func IsSnapshotChecksumError

func IsSnapshotChecksumError(err error) bool

func LoadAllSpecsFromBackup

func LoadAllSpecsFromBackup(ctx context.Context, bucket Bucket, verifier ObjectVerifier) ([]Spec, []Specless, error)

func LoadBackupManifest

func LoadBackupManifest(bucket Bucket, r *api.BackupRestoreTask) (manifest.ReleaseManifest, error)

LoadBackupManifest will return a new ReleaseManifest that has been configured with the settings in the BackupRestoreTask. By default it will return the manifest contained in the backup.

If "Upgrade" is set to true it will attempt to fetch the latest release manifest and configure it with the channel, hartifacts path and override origin.

If "Airgap" is set to true it will use the manifest contained in the airgap install bundle

func LoadDeploymentConfig

func LoadDeploymentConfig(bucket Bucket, verifier ObjectVerifier) (*deployment.AutomateConfig, error)

LoadDeploymentConfig loads the automate configuration directly from the bolt database contained in the given backup.

func SetCommandExecutor

func SetCommandExecutor(spec Spec, exec command.Executor)

SetCommandExecutor sets the command executor for a given spec

func ShowBackupChecksum

func ShowBackupChecksum(bucket Bucket) (string, error)

func ToObjectPaths

func ToObjectPaths(deleteObjs []BucketObject) []string

Types

type BackupStatus

type BackupStatus string
const (
	// BackupStatusCompleted is written to a backup that has been
	// completed successfully
	BackupStatusCompleted BackupStatus = "completed"
	// BackupStatusInProgress is written to a backup when it starts
	BackupStatusInProgress BackupStatus = "in_progress"
	// BackupStatusFailed is written to a backup when it fails
	BackupStatusFailed BackupStatus = "failed"
	// BackupStatusDeleting is written to a backup we start deleting it
	BackupStatusDeleting BackupStatus = "deleting"
)

type BlobReader

type BlobReader interface {
	io.ReadCloser
	BlobSHA256() string
}

type BlobWriter

type BlobWriter interface {
	io.WriteCloser
	Fail(error) error
	BlobSHA256() string
}

A BlobWriter is a WriteCloser that can also be failed

type Bucket

type Bucket interface {
	// NewReader returns a ReadCloser for the given storage key. The reader must be closed
	// by the caller. It is provided only when there is not an error.
	// If a object with the given name is not found, calling IsNotExist with the error
	// must return true
	NewReader(ctx context.Context, path string, verifier ObjectVerifier) (io.ReadCloser, error)

	// NewWriter returns a BlobWriter that can write to the given storage key. The data may
	// not be flushed until Close is called
	NewWriter(ctx context.Context, path string) (BlobWriter, error)

	// List returns a list of BucketObjects with the given object name prefix.
	// If there are no matching objects stored, empty lists will be returned.
	//
	// If delimited is set to true, SharedPrefix objects will be returned. Doing this is
	// equivalent to asking for a 1 level deep directory search. As an example, if pathPrefix
	// was set to 'foo/', then the directory 'foo/bar' is a possible return value, but
	// not 'foo/bar/baz'. If 'foo/quux' exists and is an object, then it would be returned in the
	// BucketObject list.
	//
	// The pathPrefix provided is assumed to end in '/'
	List(ctx context.Context, pathPrefix string, delimited bool) ([]BucketObject, []SharedPrefix, error)

	Delete(ctx context.Context, objectPaths []string) error
}

A Bucket is a place where blobs can be stored

func NewFilesystemBucket

func NewFilesystemBucket(basePath string) Bucket

NewFilesystemBucket returns a Bucket backed by a filesystem directory

func NewS3Bucket

func NewS3Bucket(name string, basePath string, c *aws.Config) (Bucket, error)

type BucketObject

type BucketObject struct {
	// The name is the name of the object in the bucket relative to the bucket
	// path. It can be a singular object name or a relative path.
	// For example, if we instantiated an s3 bucket with the bucket name
	// of foo, and a base path of bar/baz, all access to object would
	// be implicitly relative to s3://foo/bar/baz. Calling
	// NewReader(ctx, "quuz") would access s3://foo/bar/baz/quux
	Name string
}

BucketObject represents the metadata for a stored object

type CancellableTask

type CancellableTask struct {
	Status *api.BackupStatusResponse
	Cancel func()
}

type Cmd

type Cmd struct {
	Name    string   `json:"name"`
	Dump    []string `json:"dump"`
	Restore []string `json:"restore"`
}

Cmd represents a command to be run to dump/restore data from an a2 service. Commands provide a way to backup/restore data that's not stored in postgres or elasticsearch and cannot be safely copied from a service's data dir.

type CommandExecuteOperation

type CommandExecuteOperation struct {
	Name       string   `json:"name"`
	ObjectName []string `json:"storage_key"`
	Cmd        Cmd      `json:"cmd"`
	PkgOrigin  string   `json:"pkg_origin"`
	PkgName    string   `json:"pkg_name"`
	// contains filtered or unexported fields
}

CommandExecuteOperation represets a command running execution

func (*CommandExecuteOperation) Backup

func (c *CommandExecuteOperation) Backup(backupCtx Context, om ObjectManifest, progChan chan OperationProgress) error

Backup executes a backup specification.

func (*CommandExecuteOperation) Delete

func (c *CommandExecuteOperation) Delete(backupCtx Context) error

func (*CommandExecuteOperation) Restore

func (c *CommandExecuteOperation) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore executes a backup specification.

func (*CommandExecuteOperation) String

func (c *CommandExecuteOperation) String() string

String returns the string representation of the operation

type Context

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

Context is stuff

func NewContext

func NewContext(opts ...ContextOpt) Context

NewContext returns a new backup context

func (Context) DeleteBackupMetadata

func (ctx Context) DeleteBackupMetadata() error

func (*Context) IsExternalPG

func (ctx *Context) IsExternalPG() bool

func (Context) MetadataWritten

func (ctx Context) MetadataWritten(mdName string, mdData []byte)

func (Context) Transact

func (ctx Context) Transact(f TransactFunc) (string, error)

Transact runs f. It will first write a status object with 'pending'. If the function runs without error, the status object will be overwritten with 'completed'. Otherwise, it will be overwritten with 'failed'.

NOTE: Transact used to move a completed backup into place atomically. This

assumed that we could do a rename. We now use a blob like api, and
there exists no atomic rename. With the blob api, this changed to
using a status file. Since the status file did not exist before,
a successful backup is one where either there is no status file,
or one where the status file contains 'completed'.

func (Context) TransactDelete

func (ctx Context) TransactDelete(f TransactFunc) error

type ContextOpt

type ContextOpt func(*Context)

ContextOpt represents an optional configuration function for a Runner

func WithContextBackupLocationSpecification

func WithContextBackupLocationSpecification(locationSpec LocationSpecification) ContextOpt

WithContextBackupLocationSpecification configures the backup-gateway location

func WithContextBackupRestoreLocationSpecification

func WithContextBackupRestoreLocationSpecification(locationSpec LocationSpecification) ContextOpt

WithContextRestoreLocationSpecification configures the backup restore remote location

func WithContextBackupRestoreTask

func WithContextBackupRestoreTask(task *api.BackupRestoreTask) ContextOpt

WithContextBackupRestoreTask configures the context backup task

func WithContextBackupTask

func WithContextBackupTask(task *api.BackupTask) ContextOpt

WithContextBackupTask configures the context backup task

func WithContextConnFactory

func WithContextConnFactory(connFactory *secureconn.Factory) ContextOpt

WithContextConnFactory configures the secureconn.Factory to use to connect to services

func WithContextCtx

func WithContextCtx(ctx2 context.Context) ContextOpt

WithContextCtx :shrug: configures the context's context...

func WithContextEsSidecarInfo

func WithContextEsSidecarInfo(esSidecarInfo ESSidecarConnInfo) ContextOpt

WithContextEsSidecarInfo configures the EsSidecar connection info

func WithContextExternalPG

func WithContextExternalPG(isExternal bool) ContextOpt

WithContextExternalPG sets the postgres mode. If external pg is enabled, certain things like role creation will not happen.

func WithContextPgConnInfo

func WithContextPgConnInfo(info pg.ConnInfo) ContextOpt

WithContextPgConnInfo configures the context postgres connection info

func WithContextReleaseManifest

func WithContextReleaseManifest(releaseManifest manifest.ReleaseManifest) ContextOpt

WithContextReleaseManifest sets the release manifest. We need this in our testing environment to pick up the right version of things

type DatabaseDumpOperation

type DatabaseDumpOperation struct {
	Name       string   `json:"name"`
	User       string   `json:"user"`
	ObjectName []string `json:"storage_key"`
	// contains filtered or unexported fields
}

DatabaseDumpOperation represents a database that the service depends on

func (*DatabaseDumpOperation) Backup

func (d *DatabaseDumpOperation) Backup(backupCtx Context, om ObjectManifest, progChan chan OperationProgress) error

Backup executes a backup operation.

func (*DatabaseDumpOperation) Delete

func (d *DatabaseDumpOperation) Delete(backupCtx Context) error

func (*DatabaseDumpOperation) Restore

func (d *DatabaseDumpOperation) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore executes a backup operation.

func (*DatabaseDumpOperation) String

func (d *DatabaseDumpOperation) String() string

String returns the string representation of the operation

type DatabaseDumpOperationV2

type DatabaseDumpOperationV2 struct {
	Name       string   `json:"name"`
	User       string   `json:"user"`
	ObjectName []string `json:"storage_key"`
	// contains filtered or unexported fields
}

DatabaseDumpOperationV2 represents a database that the service depends on.

func (*DatabaseDumpOperationV2) Backup

func (d *DatabaseDumpOperationV2) Backup(backupCtx Context, om ObjectManifest, progChan chan OperationProgress) error

Backup executes a backup operation.

func (*DatabaseDumpOperationV2) Delete

func (d *DatabaseDumpOperationV2) Delete(backupCtx Context) error

func (*DatabaseDumpOperationV2) Restore

func (d *DatabaseDumpOperationV2) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore executes a backup operation.

func (*DatabaseDumpOperationV2) String

func (d *DatabaseDumpOperationV2) String() string

String returns the string representation of the operation

type ESSidecarConnInfo

type ESSidecarConnInfo struct {
	Host string
	Port int32
}

ESSidecarConnInfo represents how to connect to the sidecar

func (ESSidecarConnInfo) Address

func (e ESSidecarConnInfo) Address() string

Address returns an address that can be passed to grpc

type ElasticsearchOperation

type ElasticsearchOperation struct {
	ServiceName    string
	MultiIndexSpec string
}

ElasticsearchOperation represents a index in ES a service needs backed up / restored

func (*ElasticsearchOperation) Backup

func (esop *ElasticsearchOperation) Backup(backupCtx Context, _ ObjectManifest, progChan chan OperationProgress) error

Backup backs up indices in ES

func (*ElasticsearchOperation) Delete

func (esop *ElasticsearchOperation) Delete(backupCtx Context) error

func (*ElasticsearchOperation) Restore

func (esop *ElasticsearchOperation) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore executes a backup operation.

func (*ElasticsearchOperation) String

func (esop *ElasticsearchOperation) String() string

type EventHandler

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

EventHandler is a client side backup event stream handler.

func NewEventHandler

func NewEventHandler(opts ...EventHandlerOpt) *EventHandler

NewEventHandler returns a new instance of a backup event handler

func (*EventHandler) Clear

func (eh *EventHandler) Clear()

Clear clears the screen

func (*EventHandler) HandleEventError

func (eh *EventHandler) HandleEventError(event *api.DeployEvent) (completed bool, err error)

HandleEventError takes a deployment event, parses for backup event types and handles them. If an event is a completion event it'll return that the stream has completed.

type EventHandlerOpt

type EventHandlerOpt func(*EventHandler)

EventHandlerOpt represents an configuration function for the event handler

func WithWriter

func WithWriter(writer cli.FormatWriter) EventHandlerOpt

WithWriter configures the event sender's writer

type Executor

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

Executor executes synchronous and asynchronous backup operations. It listens for the operation events, annotates them, and publishes them to the status and publishing the backup status to event sender. It breaks backup execution into two phases: sync and async. All synchronous operations will be executed first, followed by asynchronous operations.

func NewExecutor

func NewExecutor(opts ...ExecutorOpt) *Executor

NewExecutor returns a new instance of a backup job executor

func (*Executor) Backup

func (b *Executor) Backup(backupCtx Context) error

Backup runs the sync and async operations and waits for them to complete. When completed or failed it publishes notifications to the event channel and notifies that runner that the operations have completed.

func (*Executor) DeleteBackup

func (b *Executor) DeleteBackup(backupCtx Context) error

func (*Executor) Restore

func (b *Executor) Restore(backupCtx Context, metadata *Metadata) error

Restore does a restores of all backup operations in the spec

func (*Executor) RestoreSyncCmds

func (b *Executor) RestoreSyncCmds(backupCtx Context, metadata *Metadata) error

RestoreSyncCmds synchronously restores cmd data of the spec

func (*Executor) RestoreSyncPaths

func (b *Executor) RestoreSyncPaths(backupCtx Context, metadata *Metadata) error

RestoreSyncPaths synchronously restores path data of the spec

type ExecutorOpt

type ExecutorOpt func(*Executor)

ExecutorOpt represents an optional configuration function for an Executor

func WithCancel

func WithCancel(canx func()) ExecutorOpt

WithCancel configures the backup execution context cancellation callback

func WithErrorChan

func WithErrorChan(c chan error) ExecutorOpt

WithErrorChan configures the error channel that the executor will publish if an operation fails.

func WithEventChan

func WithEventChan(c chan api.DeployEvent_Backup_Operation) ExecutorOpt

WithEventChan configures the event sender channel that operation events and published to.

func WithLock

func WithLock(lock *sync.Mutex) ExecutorOpt

WithLock sets the lock an executor must hold before it may do any actual backup task

func WithSpec

func WithSpec(s Spec) ExecutorOpt

WithSpec configures the backup operations from a given Spec

type FilesystemLocationSpecification

type FilesystemLocationSpecification struct {
	Path string
}

func (FilesystemLocationSpecification) ConfigureBackupRestoreTask

func (fsspec FilesystemLocationSpecification) ConfigureBackupRestoreTask(req *api.BackupRestoreTask) error

func (FilesystemLocationSpecification) String

func (fsspec FilesystemLocationSpecification) String() string

func (FilesystemLocationSpecification) ToBucket

func (fsspec FilesystemLocationSpecification) ToBucket(baseKey string) Bucket

type GatewayLocationSpecification

type GatewayLocationSpecification struct {
	BucketName string
	Endpoint   string
	BasePath   string
	AccessKey  string
	SecretKey  string
	CertPool   *x509.CertPool
}

GatewayLocationSpecification describes how to communicate with the backup gateway

func (GatewayLocationSpecification) ConfigureBackupRestoreTask

func (gws GatewayLocationSpecification) ConfigureBackupRestoreTask(req *api.BackupRestoreTask) error

ConfigureBackupRestoreTask is a NOOP callback implementation to satisfy the LocationSpecification interface.

func (GatewayLocationSpecification) String

func (gws GatewayLocationSpecification) String() string

String is the backup gateway identified as a string

func (GatewayLocationSpecification) ToBucket

func (gws GatewayLocationSpecification) ToBucket(key string) Bucket

ToBucket returns a backup bucket that can be used to communicate with the backup gateway.

type LocationSpecification

type LocationSpecification interface {
	// ToBucket converts the location specification to a bucket. All accessess have an
	// implicit prefix of baseKey
	ToBucket(baseKey string) Bucket

	// ConfigureBackupRestoreTask configures the task so that its backup location is
	// consistent with self
	ConfigureBackupRestoreTask(*api.BackupRestoreTask) error

	// String returns a string representation
	String() string
}

LocationSpecification describes where data lives. It returns a bucket to write to

func NewBackupGatewayLocationSpec

func NewBackupGatewayLocationSpec(endpoint,
	bucketName,
	basePath string,
	rootCert []byte,
	secretStore secrets.SecretStore) (LocationSpecification, error)

NewBackupGatewayLocationSpec takes the backup gateway endpoint, bucket name, base path, root TLS certificate and a secret store and returns a compatible backup location specification.

func NewRemoteLocationSpecificationFromGlobalConfig

func NewRemoteLocationSpecificationFromGlobalConfig(globalConfig *config.GlobalConfig) LocationSpecification

NewRemoteLocationSpecificationFromGlobalConfig takes the GlobalConfig and converts it into a corresponding LocationSpecification type depending on the backup location.

func NewRemoteLocationSpecificationFromRestoreTask

func NewRemoteLocationSpecificationFromRestoreTask(restoreTask *api.BackupRestoreTask) LocationSpecification

NewRemoteLocationSpecificationFromRestoreTask takes BackupRestoreTask and converts it into a corresponding LocationSpecification type depending on the backup location.

type Metadata

type Metadata struct {
	Spec                     *Spec             `json:"spec"`
	Task                     *api.BackupTask   `json:"task"`
	DeploymentServiceVersion string            `json:"deployment_service_version"`
	ContentsSHA256           map[string]string `json:"contents_sha256"`
}

Metadata is a wrapper struct for metadata that should be backed up.

func LoadServiceMetadata

func LoadServiceMetadata(bucket Bucket, svcName string, objectVerifier ObjectVerifier) (*Metadata, error)

LoadServiceMetadata takes a backup bucket and service name and returns a new Metadata instance from the backed up metadata in the given bucket. Errors caused by the metadata not existing will return true when passed to `backup.IsNotExist(err)`

func (*Metadata) Verifier

func (m *Metadata) Verifier() ObjectVerifier

type MetadataChecksums

type MetadataChecksums struct {
	ContentsSHA256 map[string]string `json:"contents_sha256"`
}

type MetadataWriterOperation

type MetadataWriterOperation struct {
	Spec       *Spec    `json:"spec"`
	ObjectName []string `json:"storage_key"`
}

MetadataWriterOperation represents an operation that writes the metadata.json

func (*MetadataWriterOperation) Backup

func (m *MetadataWriterOperation) Backup(backupCtx Context, om ObjectManifest, progChan chan OperationProgress) error

Backup executes a backup specification.

func (*MetadataWriterOperation) Delete

func (m *MetadataWriterOperation) Delete(backupCtx Context) error

func (*MetadataWriterOperation) Restore

func (m *MetadataWriterOperation) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore executes a backup specification.

func (*MetadataWriterOperation) String

func (m *MetadataWriterOperation) String() string

String returns the string representation of the operation

type NoOpObjectVerifier

type NoOpObjectVerifier struct {
}

NoOpObjectVerifier implements the ObjectVerifier interface but returns the success case for all methods. It's here for compatibility with older backups that don't have any checksums.

func (*NoOpObjectVerifier) ObjectValid

func (o *NoOpObjectVerifier) ObjectValid(objectName string) error

func (*NoOpObjectVerifier) ValidateBlobContent

func (o *NoOpObjectVerifier) ValidateBlobContent(objectName string, r BlobReader) error

type ObjectManifest

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

func NewObjectManifest

func NewObjectManifest() ObjectManifest

func (ObjectManifest) DataWritten

func (o ObjectManifest) DataWritten(objectName string, data []byte)

func (ObjectManifest) ObjectSHA256s

func (o ObjectManifest) ObjectSHA256s() map[string]string

func (ObjectManifest) WriteFinished

func (o ObjectManifest) WriteFinished(objectName string, w BlobWriter)

type ObjectVerifier

type ObjectVerifier interface {
	// ObjectValid checks if the object is present in the backup metadata to
	// prevent a malicious actor from sneaking an extra file into a backup.
	ObjectValid(objectName string) error
	ValidateBlobContent(objectName string, r BlobReader) error
}

ObjectVerifier checks objects as they are restored to ensure they have the correct checksums as recorded when they were backed up

func LoadMetadataVerifier

func LoadMetadataVerifier(bucket Bucket, sha256 string) (ObjectVerifier, error)

LoadMetadataVerifier returns an ObjectVerifier that can be used to verify the integrity of the metadata.json file for each component backup. The metadata.json files then contain checksums of the individual files in the per-service backup.

type Operation

type Operation interface {
	Backup(ctx Context, om ObjectManifest, prog chan OperationProgress) error
	Restore(ctx Context, serviceName string, verifier ObjectVerifier, prog chan OperationProgress) error
	Delete(ctx Context) error
	String() string
}

Operation is an interface for a backup operation.

type OperationProgress

type OperationProgress struct {
	Name     string
	Progress float64
}

OperationProgress represents an operations current progress

type PathCopyOperation

type PathCopyOperation struct {
	Name          string         `json:"name"`
	ObjectName    []string       `json:"storage_key"`
	SrcPath       string         `json:"src_path"`
	RsyncMatchers []RsyncMatcher `json:"-"` // don't marshal an interface
	Owner         string
	// contains filtered or unexported fields
}

PathCopyOperation backups a source path to a destination path. It also supports a slice of optional Rsync matchers to include or exclude files or directories from the source path.

func (*PathCopyOperation) Backup

func (p *PathCopyOperation) Backup(backupCtx Context, om ObjectManifest, progChan chan OperationProgress) error

Backup backs up a path using the defined fields on the struct and publishes progress events to the progress channel.

func (*PathCopyOperation) Delete

func (p *PathCopyOperation) Delete(backupCtx Context) error

func (*PathCopyOperation) Restore

func (p *PathCopyOperation) Restore(backupCtx Context, serviceName string, verifier ObjectVerifier, progChan chan OperationProgress) error

Restore restores a path using the defined fields on the struct and publishes progress events to the progress channel.

func (*PathCopyOperation) String

func (p *PathCopyOperation) String() string

String returns the string representation of the operation

type ProgressCalculator

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

ProgressCalculator tracks the progress of multiple operations

func NewProgressCalculator

func NewProgressCalculator() *ProgressCalculator

NewProgressCalculator returns a new initialized ProgressCalculator

func (*ProgressCalculator) Done

func (p *ProgressCalculator) Done()

Done sets all operations in the progress calculator to 100%

func (*ProgressCalculator) Percent

func (p *ProgressCalculator) Percent() float64

Percent returns the average completion percent between all operations in the progress calculator. It's a bit microsoftian in that some operations may run much longer than others.

func (*ProgressCalculator) Update

func (p *ProgressCalculator) Update(op OperationProgress)

Update updates an operation in the progress calculator

type RequiredChecksumDataMissingError

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

func (*RequiredChecksumDataMissingError) Error

type RsyncExclude

type RsyncExclude struct {
	Pattern string
}

RsyncExclude is the concreate type for an rsync exclude rule

func (*RsyncExclude) RsyncArgs

func (r *RsyncExclude) RsyncArgs() (flag, matcher string)

RsyncArgs give the rsync args for the exclude filter

type RsyncInclude

type RsyncInclude struct {
	Pattern string
}

RsyncInclude is the concrete type for an rsync include rule

func (*RsyncInclude) RsyncArgs

func (r *RsyncInclude) RsyncArgs() (flag, matcher string)

RsyncArgs gives the rsync args for the include filter

type RsyncMatcher

type RsyncMatcher interface {
	RsyncArgs() (flag, matcher string)
}

RsyncMatcher is a rsync include or exclude pattern

func Exclude

func Exclude(rsyncPattern string) RsyncMatcher

Exclude creates an RsyncMatcher representing a `--exclude PATTERN` argument to rsync

func Include

func Include(rsyncPattern string) RsyncMatcher

Include creates an RsyncMatcher representing a `--include PATTERN` argument to rsync

type Runner

type Runner struct {

	// map[task-id][service-name] = operation-status
	TaskOperations map[string]map[string]api.DeployEvent_Backup_Operation
	// contains filtered or unexported fields
}

Runner represents a new backup runner

func NewRunner

func NewRunner(opts ...RunnerOpt) *Runner

NewRunner returns a new instance of a backup job runner

func (*Runner) Cancel

func (r *Runner) Cancel(ctx context.Context) error

Cancel cancels the currently running backup operation. If the current operation is IDLE it will return an error.

func (*Runner) Configure

func (r *Runner) Configure(opts ...RunnerOpt) *Runner

Configure updates the instance with RunnerOpt's

func (*Runner) CreateBackup

func (r *Runner) CreateBackup(ctx context.Context, dep *deployment.Deployment, sender events.EventSender) (*api.BackupTask, error)

CreateBackup creates an Automate Backup

func (*Runner) DeleteBackups

func (r *Runner) DeleteBackups(ctx context.Context, dep *deployment.Deployment, backupTasks []*api.BackupTask) error

DeleteBackups deletes one or many Automate Backups

func (*Runner) ListBackups

func (r *Runner) ListBackups(ctx context.Context) ([]*api.BackupTask, error)

ListBackups lists all of the available backups

func (*Runner) RestoreBackup

RestoreBackup starts a backup restoration in a go routine and returns the task.

func (*Runner) RunningTask

func (r *Runner) RunningTask(ctx context.Context) *CancellableTask

RunningTask returns the currently running backup task

func (*Runner) ShowBackup

func (r *Runner) ShowBackup(ctx context.Context, t *api.BackupTask) (*api.BackupDescription, error)

type RunnerOpt

type RunnerOpt func(*Runner)

RunnerOpt represents an optional configuration function for a Runner

func WithBackupLocationSpecification

func WithBackupLocationSpecification(locationSpec LocationSpecification) RunnerOpt

WithBackupLocationSpecification sets the backup-gateway location

func WithConfigRenderer

func WithConfigRenderer(f func(*deployment.Service) (string, error)) RunnerOpt

WithConfigRenderer configures the runner to unlock the given deployment.

func WithConnFactory

func WithConnFactory(connFactory *secureconn.Factory) RunnerOpt

WithConnFactory configures the secureconn.Factory to use to connect to services

func WithDeploymentStore

func WithDeploymentStore(deploymentStore persistence.DeploymentStore) RunnerOpt

WithDeploymentStore sets the deployment store for the runner

func WithEsSidecarInfo

func WithEsSidecarInfo(esSidecarInfo ESSidecarConnInfo) RunnerOpt

WithEsSidecarInfo configures the EsSidecar connection info

func WithPGConnInfo

func WithPGConnInfo(pgConnInfo pg.ConnInfo) RunnerOpt

WithPGConnInfo sets the pgsql info to use

func WithReleaseManifest

func WithReleaseManifest(releaseManifest manifest.ReleaseManifest) RunnerOpt

WithReleaseManifest sets the release manifest for the runner

func WithSpecs

func WithSpecs(specs []Spec) RunnerOpt

WithSpecs configures the backup specifications to run

func WithTarget

func WithTarget(target target.Target) RunnerOpt

WithTarget sets the runners deployment target

type S3LocationSpecification

type S3LocationSpecification struct {
	// Required
	BucketName string
	Endpoint   string

	// Optional
	BasePath     string
	AccessKey    string
	SecretKey    string
	SessionToken string
}

func (S3LocationSpecification) ConfigureBackupRestoreTask

func (s3spec S3LocationSpecification) ConfigureBackupRestoreTask(req *api.BackupRestoreTask) error

func (S3LocationSpecification) String

func (s3spec S3LocationSpecification) String() string

func (S3LocationSpecification) ToBucket

func (s3spec S3LocationSpecification) ToBucket(baseKey string) Bucket

type SHA256Verifier

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

func (*SHA256Verifier) ObjectValid

func (o *SHA256Verifier) ObjectValid(objectName string) error

func (*SHA256Verifier) ValidateBlobContent

func (o *SHA256Verifier) ValidateBlobContent(objectName string, r BlobReader) error

type SharedPrefix

type SharedPrefix string

SharedPrefix represents a group of object names that exist

type SnapshotChecksumMismatchError

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

func (*SnapshotChecksumMismatchError) Error

type SnapshotChecksumMissingError

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

func (*SnapshotChecksumMissingError) Error

type Spec

type Spec struct {
	// Name of the a2 service to be backed up
	Name string `json:"name"`

	// Version of the backup specification. If the specification changes such
	// that a backup created by the older specification cannot be properly
	// restored by the newer specification, then both must be defined and the
	// newer one should be a new version.
	Version int `json:"version"`

	// Write the backup metadata
	WriteMetadata bool `json:"metadata"`

	// Paths to back up. Broken down into which phase of the backup they
	// should run.
	SyncPaths  []PathCopyOperation `json:"sync_paths"`
	AsyncPaths []PathCopyOperation `json:"async_paths"`

	// Backup commands to run. Broken down into which phase of the backup they
	// should run.
	SyncCmds  []CommandExecuteOperation `json:"sync_cmds"`
	AsyncCmds []CommandExecuteOperation `json:"async_cmds"`

	// Databases to dump. Broken down into which phase the database dumps should
	// occur. When DB operations have been implemented they should be used here.
	SyncDbsV2  []DatabaseDumpOperationV2 `json:"sync_dbs_v2"`
	AsyncDbsV2 []DatabaseDumpOperationV2 `json:"async_dbs_v2"`

	SyncEsIndices  []ElasticsearchOperation `json:"sync_es"`
	AsyncEsIndices []ElasticsearchOperation `json:"async_es"`

	// DEPRECATED
	SyncDbs  []DatabaseDumpOperation `json:"sync_dbs"`
	AsyncDbs []DatabaseDumpOperation `json:"async_dbs"`
	// contains filtered or unexported fields
}

Spec describes the operations required to backup a given service

func DefaultSpecs

func DefaultSpecs(chefServerEnabled bool, workflowEnabled bool) []Spec

DefaultSpecs returns a list of backup specifications

func (*Spec) AsyncOps

func (s *Spec) AsyncOps() []Operation

AsyncOps returns a slice of Operations that should be run asynchronously

func (*Spec) FinalizingOps

func (s *Spec) FinalizingOps() []Operation

FinalizingOps returns a slice of Operations that should be run after the synchronous and asynchronous data backup operations have completed. Currently this includes only the MetadataWriterOperation, if the relevant service supports it.

func (*Spec) SyncOps

func (s *Spec) SyncOps() []Operation

SyncOps returns a slice of Operations that should be run synchronously

type Specless

type Specless = string

type TransactFunc

type TransactFunc func(Context) error

TransactFunc is a function to execute that takes a backup context

Jump to

Keyboard shortcuts

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