Documentation ¶
Overview ¶
Copyright 2018 the Heptio Ark contributors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AzureCmdEnv(backupLocationLister arkv1listers.BackupStorageLocationLister, ...) ([]string, error)
- func EnsureCommonRepositoryKey(secretClient corev1client.SecretsGetter, namespace string) error
- func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string
- func GetRepoIdentifier(location *arkv1api.BackupStorageLocation, name string) string
- func GetRepositoryKey(secretGetter SecretGetter, namespace string) ([]byte, error)
- func GetSnapshotID(repoIdentifier, passwordFile string, tags map[string]string, env []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 AzureCmdEnv ¶
func AzureCmdEnv(backupLocationLister arkv1listers.BackupStorageLocationLister, namespace, backupLocation string) ([]string, error)
AzureCmdEnv returns a list of environment variables (in the format var=val) that should be used when running a restic command for an Azure backend. This list is the current environment, plus the Azure-specific variables restic needs, namely a storage account name and key.
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(location *arkv1api.BackupStorageLocation, 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, env []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 ¶
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 Env []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(repo *arkv1api.ResticRepository) error // CheckRepo checks the specified repo for errors. CheckRepo(repo *arkv1api.ResticRepository) error // PruneRepo deletes unused data from a repo. PruneRepo(repo *arkv1api.ResticRepository) 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, backupLocationInformer arkv1informers.BackupStorageLocationInformer, 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, backupLocation 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 { // VolumeNamespace is the namespace of the pod/volume that // the restic snapshot is for. VolumeNamespace string // BackupStorageLocation is the backup's storage location // name. BackupStorageLocation 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.