Velero: Exclude resource from backup by a standard label

Created on 16 Apr 2019  路  5Comments  路  Source: vmware-tanzu/velero

Describe the solution you'd like
Provide a standard label that when applied to a resource will exclude that resource from being backed up.

_Example:_

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: do-not-backup
  namespace: default
  labels:
    # Any resource with this a standard label/value will be excluded from all backups.
    velero.io/backup-excluded: "true"
data:
  foo: {{bar}}

Anything else you would like to add:

Our specific use-case is for cluster migrations. We'd like to prevent a small subset of the resources that are created during cluster bootstrap (applying manifests via Ansible) being overwritten when we apply a restore. The restore from another cluster may include cluster-specific configuration that would be invalid in the new cluster, so there is no point in backing those resources up given that we will bootstrap them.

_Our Current solution:_

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-specific-config-created-at-cluster-bootstrap
  namespace: default
  labels:
    backup: "false" # Include our own standard label.
data:
  clusterSpecificData: {{cluster_specific_data}}
# Use a label selector to filter where backup==false
ark backup create example -l 'backup notin (false)'

I understand there are alternatives but this seems like a simple way for us to cherry-pick out certain resources that should not be backed up. What do you think?

Environment:

  • Velero version (use velero version): 0.10.0
  • Kubernetes version (use kubectl version): 1.10
  • Kubernetes installer & version: Terraform & Ansible
  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release):
EnhancemenUser Good first issue Help wanted

Most helpful comment

Here's where we list items from the API server for each resource type:
https://github.com/heptio/velero/blob/master/pkg/backup/resource_backupper.go#L230

This currently takes a label selector from the backup spec. We'd probably want to add a requirement to it to exclude items containing this new "exclude-from-backup" label.

All 5 comments

@brandon-mcrae-hs yeah, this seems like a nice feature to add. Maybe velero.io/exclude-from-backup?

Are you interested in contributing a PR for this? I can help point you in the right direction, if so.

cc @nrb @carlisia

@skriss Possibly, I'll see if I can find some time for it. Would "pointing me in the right direction" be generally useful if posted here? That way if someone else gets to this first they will have the same information?

I like velero.io/exclude-from-backup, it reads well.

Yeah, I'll add some notes here shortly. Thanks!

What, we don't have that?? :) Great idea.

Here's where we list items from the API server for each resource type:
https://github.com/heptio/velero/blob/master/pkg/backup/resource_backupper.go#L230

This currently takes a label selector from the backup spec. We'd probably want to add a requirement to it to exclude items containing this new "exclude-from-backup" label.

Was this page helpful?
0 / 5 - 0 ratings