Documentation ¶
Index ¶
- Constants
- func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string
- func GetRepositoryKey(secretGetter SecretGetter, namespace string) ([]byte, error)
- func GetSnapshotID(repoPrefix, repo, passwordFile string, tags map[string]string) (string, error)
- func GetVolumesToBackup(obj metav1.Object) []string
- func NewRepositoryKey(secretClient corev1client.SecretsGetter, namespace string, data []byte) error
- func PodHasSnapshotAnnotation(obj metav1.Object) bool
- func SetPodSnapshotAnnotation(obj metav1.Object, volumeName, snapshotID string)
- func TempCredentialsFile(secretLister corev1listers.SecretLister, repoName string) (string, error)
- type BackendType
- type Backupper
- type BackupperFactory
- type Command
- func BackupCommand(repoPrefix, repo, passwordFile, path string, tags map[string]string) *Command
- func CheckCommand(repoPrefix, repo string) *Command
- func ForgetCommand(repoPrefix, repo, snapshotID string) *Command
- func GetSnapshotCommand(repoPrefix, repo, passwordFile string, tags map[string]string) *Command
- func InitCommand(repoPrefix, repo string) *Command
- func PruneCommand(repoPrefix, repo string) *Command
- func RestoreCommand(repoPrefix, repo, passwordFile, podUID, snapshotID string) *Command
- type RepositoryManager
- type Restorer
- type RestorerFactory
- type SecretGetter
- type SnapshotIdentifier
Constants ¶
const ( CredentialsSecretName = "ark-restic-credentials" CredentialsKey = "ark-restic-credentials" )
const (
InitContainer = "restic-wait"
)
Variables ¶
This section is empty.
Functions ¶
func GetPodSnapshotAnnotations ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
BackupCommand returns a Command for running a restic backup.
func CheckCommand ¶
func ForgetCommand ¶
func GetSnapshotCommand ¶
GetSnapshotCommand returns a Command for running a restic (get) snapshots.
func InitCommand ¶
func PruneCommand ¶
func RestoreCommand ¶
RestoreCommand returns a Command for running a restic restore.
func (*Command) StringSlice ¶
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 ¶
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.