restic

package
v0.9.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CredentialsSecretName = "ark-restic-credentials"
	CredentialsKey        = "ark-restic-credentials"
)
View Source
const (
	InitContainer = "restic-wait"
)

Variables

This section is empty.

Functions

func GetPodSnapshotAnnotations

func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string

GetPodSnapshotAnnotations returns a map, of volume name -> snapshot id, of all restic snapshots for this pod.

func GetRepositoryKey

func GetRepositoryKey(secretGetter SecretGetter, namespace string) ([]byte, error)

func GetSnapshotID

func GetSnapshotID(repoPrefix, repo, passwordFile string, tags map[string]string) (string, error)

GetSnapshotID runs a 'restic snapshots' command to get the ID of the snapshot in the specified repo matching the set of provided tags, or an error if a unique snapshot cannot be identified.

func GetVolumesToBackup

func GetVolumesToBackup(obj metav1.Object) []string

GetVolumesToBackup returns a list of volume names to backup for the provided pod.

func NewRepositoryKey

func NewRepositoryKey(secretClient corev1client.SecretsGetter, namespace string, data []byte) error

func PodHasSnapshotAnnotation

func PodHasSnapshotAnnotation(obj metav1.Object) bool

PodHasSnapshotAnnotation returns true if the object has an annotation indicating that there is a restic snapshot for a volume in this pod, or false otherwise.

func SetPodSnapshotAnnotation

func SetPodSnapshotAnnotation(obj metav1.Object, volumeName, snapshotID string)

SetPodSnapshotAnnotation adds an annotation to a pod to indicate that the specified volume has a restic snapshot with the provided id.

func TempCredentialsFile

func TempCredentialsFile(secretLister corev1listers.SecretLister, repoName string) (string, error)

TempCredentialsFile creates a temp file containing a restic encryption key for the given repo and returns its path. The caller should generally call os.Remove() to remove the file when done with it.

Types

type BackendType

type BackendType string
const (
	AWSBackend   BackendType = "aws"
	AzureBackend BackendType = "azure"
	GCPBackend   BackendType = "gcp"
)

type Backupper

type Backupper interface {
	// BackupPodVolumes backs up all annotated volumes in a pod.
	BackupPodVolumes(backup *arkv1api.Backup, pod *corev1api.Pod, log logrus.FieldLogger) (map[string]string, []error)
}

Backupper can execute restic backups of volumes in a pod.

type BackupperFactory

type BackupperFactory interface {
	// NewBackupper returns a restic backupper for use during a single
	// Ark backup.
	NewBackupper(context.Context, *arkv1api.Backup) (Backupper, error)
}

BackupperFactory can construct restic backuppers.

type Command

type Command struct {
	BaseName     string
	Command      string
	RepoPrefix   string
	Repo         string
	PasswordFile string
	Args         []string
	ExtraFlags   []string
}

Command represents a restic command.

func BackupCommand

func BackupCommand(repoPrefix, repo, passwordFile, path string, tags map[string]string) *Command

BackupCommand returns a Command for running a restic backup.

func CheckCommand

func CheckCommand(repoPrefix, repo string) *Command

func ForgetCommand

func ForgetCommand(repoPrefix, repo, snapshotID string) *Command

func GetSnapshotCommand

func GetSnapshotCommand(repoPrefix, repo, passwordFile string, tags map[string]string) *Command

GetSnapshotCommand returns a Command for running a restic (get) snapshots.

func InitCommand

func InitCommand(repoPrefix, repo string) *Command

func PruneCommand

func PruneCommand(repoPrefix, repo string) *Command

func RestoreCommand

func RestoreCommand(repoPrefix, repo, passwordFile, podUID, snapshotID string) *Command

RestoreCommand returns a Command for running a restic restore.

func (*Command) Cmd

func (c *Command) Cmd() *exec.Cmd

Cmd returns an exec.Cmd for the command.

func (*Command) String

func (c *Command) String() string

String returns the command as a string.

func (*Command) StringSlice

func (c *Command) StringSlice() []string

StringSlice returns the command as a slice of strings.

type RepositoryManager

type RepositoryManager interface {
	// CheckRepo checks the specified repo for errors.
	CheckRepo(name string) error

	// CheckAllRepos checks all repos for errors.
	CheckAllRepos() error

	// PruneRepo deletes unused data from a repo.
	PruneRepo(name string) error

	// PruneAllRepos deletes unused data from all
	// repos.
	PruneAllRepos() error

	// Forget removes a snapshot from the list of
	// available snapshots in a repo.
	Forget(snapshot SnapshotIdentifier) error

	BackupperFactory

	RestorerFactory
}

RepositoryManager executes commands against restic repositories.

func NewRepositoryManager

func NewRepositoryManager(
	ctx context.Context,
	objectStore cloudprovider.ObjectStore,
	config arkv1api.ObjectStorageProviderConfig,
	arkClient clientset.Interface,
	secretsInformer cache.SharedIndexInformer,
	secretsClient corev1client.SecretsGetter,
	log logrus.FieldLogger,
) (RepositoryManager, error)

NewRepositoryManager constructs a RepositoryManager.

type Restorer

type Restorer interface {
	// RestorePodVolumes restores all annotated volumes in a pod.
	RestorePodVolumes(restore *arkv1api.Restore, pod *corev1api.Pod, log logrus.FieldLogger) []error
}

Restorer can execute restic restores of volumes in a pod.

type RestorerFactory

type RestorerFactory interface {
	// NewRestorer returns a restic restorer for use during a single
	// Ark restore.
	NewRestorer(context.Context, *arkv1api.Restore) (Restorer, error)
}

RestorerFactory can construct restic restorers.

type SecretGetter

type SecretGetter interface {
	GetSecret(namespace, name string) (*corev1api.Secret, error)
}

func NewClientSecretGetter

func NewClientSecretGetter(client corev1client.SecretsGetter) SecretGetter

func NewListerSecretGetter

func NewListerSecretGetter(lister corev1listers.SecretLister) SecretGetter

type SnapshotIdentifier

type SnapshotIdentifier struct {
	// Repo is the name of the restic repository where the
	// snapshot is located
	Repo string

	// SnapshotID is the short ID of the restic snapshot
	SnapshotID string
}

SnapshotIdentifier uniquely identifies a restic snapshot taken by Ark.

func GetSnapshotsInBackup

func GetSnapshotsInBackup(backup *arkv1api.Backup, podVolumeBackupLister arkv1listers.PodVolumeBackupLister) ([]SnapshotIdentifier, error)

GetSnapshotsInBackup returns a list of all restic snapshot ids associated with a given Ark backup.

Jump to

Keyboard shortcuts

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