add velero server flag to allow default restic use on all pod volumes
Signed-off-by: Ashish Amarnath <ashisham@vmware.com>pull/2611/head
parent
dd11b175ec
commit
b71173228a
|
@ -71,6 +71,7 @@ type kubernetesBackupper struct {
|
|||
podCommandExecutor podexec.PodCommandExecutor
|
||||
resticBackupperFactory restic.BackupperFactory
|
||||
resticTimeout time.Duration
|
||||
defaultRestic bool
|
||||
}
|
||||
|
||||
type resolvedAction struct {
|
||||
|
@ -103,6 +104,7 @@ func NewKubernetesBackupper(
|
|||
podCommandExecutor podexec.PodCommandExecutor,
|
||||
resticBackupperFactory restic.BackupperFactory,
|
||||
resticTimeout time.Duration,
|
||||
defaultRestic bool,
|
||||
) (Backupper, error) {
|
||||
return &kubernetesBackupper{
|
||||
backupClient: backupClient,
|
||||
|
@ -111,6 +113,7 @@ func NewKubernetesBackupper(
|
|||
podCommandExecutor: podCommandExecutor,
|
||||
resticBackupperFactory: resticBackupperFactory,
|
||||
resticTimeout: resticTimeout,
|
||||
defaultRestic: defaultRestic,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -240,6 +243,11 @@ func (kb *kubernetesBackupper) Backup(log logrus.FieldLogger, backupRequest *Req
|
|||
log.Infof("Including resources: %s", backupRequest.ResourceIncludesExcludes.IncludesString())
|
||||
log.Infof("Excluding resources: %s", backupRequest.ResourceIncludesExcludes.ExcludesString())
|
||||
|
||||
if backupRequest.Backup.Spec.DefaultRestic == nil {
|
||||
backupRequest.Backup.Spec.DefaultRestic = &kb.defaultRestic
|
||||
}
|
||||
log.Infof("Backing up all pod volumes using restic: %t", *backupRequest.Backup.Spec.DefaultRestic)
|
||||
|
||||
var err error
|
||||
backupRequest.ResourceHooks, err = getResourceHooks(backupRequest.Spec.Hooks.Resources, kb.discoveryHelper)
|
||||
if err != nil {
|
||||
|
|
|
@ -126,6 +126,7 @@ type serverConfig struct {
|
|||
profilerAddress string
|
||||
formatFlag *logging.FormatFlag
|
||||
defaultResticMaintenanceFrequency time.Duration
|
||||
defaultRestic bool
|
||||
}
|
||||
|
||||
type controllerRunInfo struct {
|
||||
|
@ -152,6 +153,7 @@ func NewCommand(f client.Factory) *cobra.Command {
|
|||
resourceTerminatingTimeout: defaultResourceTerminatingTimeout,
|
||||
formatFlag: logging.NewFormatFlag(),
|
||||
defaultResticMaintenanceFrequency: restic.DefaultMaintenanceFrequency,
|
||||
defaultRestic: restic.DefaultRestic,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -213,6 +215,7 @@ func NewCommand(f client.Factory) *cobra.Command {
|
|||
command.Flags().DurationVar(&config.resourceTerminatingTimeout, "terminating-resource-timeout", config.resourceTerminatingTimeout, "how long to wait on persistent volumes and namespaces to terminate during a restore before timing out")
|
||||
command.Flags().DurationVar(&config.defaultBackupTTL, "default-backup-ttl", config.defaultBackupTTL, "how long to wait by default before backups can be garbage collected")
|
||||
command.Flags().DurationVar(&config.defaultResticMaintenanceFrequency, "default-restic-prune-frequency", config.defaultResticMaintenanceFrequency, "how often 'restic prune' is run for restic repositories by default")
|
||||
command.Flags().BoolVar(&config.defaultRestic, "default-restic", config.defaultRestic, "backup all volumes with restic by default")
|
||||
|
||||
return command
|
||||
}
|
||||
|
@ -637,6 +640,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
|
|||
podexec.NewPodCommandExecutor(s.kubeClientConfig, s.kubeClient.CoreV1().RESTClient()),
|
||||
s.resticManager,
|
||||
s.config.podVolumeOperationTimeout,
|
||||
s.config.defaultRestic,
|
||||
)
|
||||
cmd.CheckError(err)
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ const (
|
|||
// at which restic prune is run.
|
||||
DefaultMaintenanceFrequency = 7 * 24 * time.Hour
|
||||
|
||||
// DefaultRestic specifies whether restic should be used, by default, to
|
||||
// take backup of all pod volumes.
|
||||
DefaultRestic = false
|
||||
|
||||
// PVCNameAnnotation is the key for the annotation added to
|
||||
// pod volume backups when they're for a PVC.
|
||||
PVCNameAnnotation = "velero.io/pvc-name"
|
||||
|
|
Loading…
Reference in New Issue