restic

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DaemonSet                   = "restic"
	InitContainer               = "restic-wait"
	DefaultMaintenanceFrequency = 24 * time.Hour
)
View Source
const (
	CredentialsSecretName = "ark-restic-credentials"
	CredentialsKey        = "repository-password"
)

Variables

This section is empty.

Functions

func EnsureCommonRepositoryKey

func EnsureCommonRepositoryKey(secretClient corev1client.SecretsGetter, namespace string) error

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 GetRepoIdentifier

func GetRepoIdentifier(config arkv1api.ObjectStorageProviderConfig, name string) string

GetRepoIdentifier returns the string to be used as the value of the --repo flag in restic commands for the given repository.

func GetRepositoryKey

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

func GetSnapshotID

func GetSnapshotID(repoIdentifier, 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 NewPodVolumeBackupListOptions

func NewPodVolumeBackupListOptions(name, uid string) metav1.ListOptions

NewPodVolumeBackupListOptions creates a ListOptions with a label selector configured to find PodVolumeBackups for the backup identified by name and uid.

func NewPodVolumeRestoreListOptions

func NewPodVolumeRestoreListOptions(name, uid string) metav1.ListOptions

NewPodVolumeRestoreListOptions creates a ListOptions with a label selector configured to find PodVolumeRestores for the restore identified by name and uid.

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, arkNamespace, repoName string, fs filesystem.Interface) (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 {
	Command        string
	RepoIdentifier string
	PasswordFile   string
	Dir            string
	Args           []string
	ExtraFlags     []string
}

Command represents a restic command.

func BackupCommand

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

BackupCommand returns a Command for running a restic backup.

func CheckCommand

func CheckCommand(repoIdentifier string) *Command

func ForgetCommand

func ForgetCommand(repoIdentifier, snapshotID string) *Command

func GetSnapshotCommand

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

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

func InitCommand

func InitCommand(repoIdentifier string) *Command

func PruneCommand

func PruneCommand(repoIdentifier string) *Command

func RestoreCommand

func RestoreCommand(repoIdentifier, passwordFile, snapshotID, target 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) RepoName

func (c *Command) RepoName() string

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 {
	// InitRepo initializes a repo with the specified name and identifier.
	InitRepo(name, identifier string) error

	// CheckRepo checks the specified repo for errors.
	CheckRepo(name, identifier string) error

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

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

	BackupperFactory

	RestorerFactory
}

RepositoryManager executes commands against restic repositories.

func NewRepositoryManager

func NewRepositoryManager(
	ctx context.Context,
	namespace string,
	arkClient clientset.Interface,
	secretsInformer cache.SharedIndexInformer,
	repoInformer arkv1informers.ResticRepositoryInformer,
	repoClient arkv1client.ResticRepositoriesGetter,
	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.

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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