Documentation ¶
Index ¶
- Constants
- func EnsureCommonRepositoryKey(secretClient corev1client.SecretsGetter, namespace string) error
- func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string
- func GetRepoIdentifier(config arkv1api.ObjectStorageProviderConfig, name string) string
- func GetRepositoryKey(secretGetter SecretGetter, namespace string) ([]byte, error)
- func GetSnapshotID(repoIdentifier, passwordFile string, tags map[string]string) (string, error)
- func GetVolumesToBackup(obj metav1.Object) []string
- func NewPodVolumeBackupListOptions(name, uid string) metav1.ListOptions
- func NewPodVolumeRestoreListOptions(name, uid string) metav1.ListOptions
- func PodHasSnapshotAnnotation(obj metav1.Object) bool
- func SetPodSnapshotAnnotation(obj metav1.Object, volumeName, snapshotID string)
- func TempCredentialsFile(secretLister corev1listers.SecretLister, arkNamespace, repoName string, ...) (string, error)
- type BackendType
- type Backupper
- type BackupperFactory
- type Command
- func BackupCommand(repoIdentifier, passwordFile, path string, tags map[string]string) *Command
- func CheckCommand(repoIdentifier string) *Command
- func ForgetCommand(repoIdentifier, snapshotID string) *Command
- func GetSnapshotCommand(repoIdentifier, passwordFile string, tags map[string]string) *Command
- func InitCommand(repoIdentifier string) *Command
- func PruneCommand(repoIdentifier string) *Command
- func RestoreCommand(repoIdentifier, passwordFile, snapshotID, target string) *Command
- type RepositoryManager
- type Restorer
- type RestorerFactory
- type SecretGetter
- type SnapshotIdentifier
Constants ¶
const ( DaemonSet = "restic" InitContainer = "restic-wait" DefaultMaintenanceFrequency = 24 * time.Hour )
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 ¶
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 ¶
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 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 ¶
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, 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 ¶
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 { // 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, sourceNamespace string, 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.