Skip to content

Commit

Permalink
Allow backup storage locations to toggle off backup sync
Browse files Browse the repository at this point in the history
Signed-off-by: Antony Bett <[email protected]>
  • Loading branch information
betta1 committed Oct 3, 2019
1 parent c8f1d0d commit 0aa7035
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/1936-betta1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow backup storage locations to specify backup sync period or toggle off sync
10 changes: 6 additions & 4 deletions pkg/cloudprovider/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import (

// ValidateObjectStoreConfigKeys ensures that an object store's config
// is valid by making sure each `config` key is in the `validKeys` list.
// The special keys "bucket", "prefix" and "backupSyncPeriod" are always
// considered valid.
// The special keys "bucket", "prefix", "backupSyncPeriod" and "skipBackupSync"
// are always considered valid.
func ValidateObjectStoreConfigKeys(config map[string]string, validKeys ...string) error {
// `bucket`, `prefix` are automatically added to all object store
// config by velero, so add them as valid keys. Object store config
// can also specify a `backupSyncPeriod` so add this as a valid key.
return validateConfigKeys(config, append(validKeys, "bucket", "prefix", "backupSyncPeriod")...)
// can also specify `backupSyncPeriod` and `skipBackupSync`, so add
// them as a valid keys.
return validateConfigKeys(config, append(validKeys, "bucket",
"prefix", "backupSyncPeriod", "skipBackupSync")...)
}

// ValidateVolumeSnapshotterConfigKeys ensures that a volume snapshotter's
Expand Down
15 changes: 15 additions & 0 deletions pkg/controller/backup_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controller

import (
"encoding/json"
"strconv"
"time"

"github.com/pkg/errors"
Expand All @@ -39,6 +40,7 @@ import (

const (
backupSyncPeriodKey = "backupSyncPeriod"
skipBackupSyncKey = "skipBackupSync"
)

type backupSyncController struct {
Expand Down Expand Up @@ -139,6 +141,19 @@ func (c *backupSyncController) run() {
for _, location := range locations {
log := c.logger.WithField("backupLocation", location.Name)

if skipBackupSync, ok := location.Spec.Config[skipBackupSyncKey]; ok {
skipSync, err := strconv.ParseBool(skipBackupSync)
if err != nil {
log.WithError(err).Error("Error parsing skipBackupSync (expected bool)")
continue
}

if skipSync {
log.Debug("skipBackupSync set to true, skipping backup sync for this location")
continue
}
}

if backupSyncPeriod, ok := location.Spec.Config[backupSyncPeriodKey]; ok {
syncDuration, err := time.ParseDuration(backupSyncPeriod)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions site/docs/master/api-types/backupstoragelocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The configurable parameters are as follows:
| `objectStorage/prefix` | String | Optional Field | The directory inside a storage bucket where backups are to be uploaded. |
| `config` | map[string]string<br><br>(See the corresponding [AWS][0], [GCP][1], and [Azure][2]-specific configs or your provider's documentation.) | None (Optional) | Configuration keys/values to be passed to the cloud provider for backup storage. |
| `config/backupSyncPeriod` | time.Duration | Optional Field | How frequently Velero should synchronize backups in object storage. Default is Velero's server global backup sync period. |
| `config/skipBackupSync` | bool | Optional Field | Set this to `true` if you want Velero to skip synchronizing backups in object storage. |
| `accessMode` | String | `ReadWrite` | How Velero can access the backup storage location. Valid values are `ReadWrite`, `ReadOnly`. |


Expand Down

0 comments on commit 0aa7035

Please sign in to comment.