Skip to main content

Velero Backup Resource for Snapshots

This topic provides information about the supported fields in the Velero Backup resource for the Replicated KOTS snapshots feature.

Overview

The Velero Backup custom resource enables the KOTS snapshots backup and restore feature. The backend of this feature uses the Velero open source project to back up Kubernetes manifests and persistent volumes.

Example

The following shows an example of the Velero Backup resource:

apiVersion: velero.io/v1
kind: Backup
metadata:
name: backup
annotations:
# `pvc-volume` will be the only volume included in the backup
backup.velero.io/backup-volumes: pvc-volume
spec:
includedNamespaces:
- '*'
excludedNamespaces:
- some-namespace
orderedResources:
pods: mysql/mysql-cluster-replica-0,mysql/mysql-cluster-replica-1
persistentvolumes: pvc-12345,pvc-67890
ttl: 720h
hooks:
resources:
-
name: my-hook
includedNamespaces:
- '*'
excludedNamespaces:
- some-namespace
includedResources:
- pods
excludedResources: []
labelSelector:
matchLabels:
app: velero
component: server
pre:
-
exec:
container: my-container
command:
- /bin/uname
- -a
onError: Fail
timeout: 10s
post: []

Supported Fields for Full Backups with Snapshots

For partial backups with the snapshots feature, you can use all of the fields that Velero supports. See Backups in the Velero documentation.

However, not all fields are supported for full backups. The table below lists the fields that are supported for full backups with snapshots:

Field NameDescription
includedNamespaces(Optional) Specifies an array of namespaces to include in the backup. If unspecified, all namespaces are included.
excludedNamespaces(Optional) Specifies an array of namespaces to exclude from the backup.
orderedResources(Optional) Specifies the order of the resources to collect during the backup process. This is a map that uses a key as the plural resource. Each resource name has the format NAMESPACE/OBJECTNAME. The object names are a comma delimited list. For cluster resources, use OBJECTNAME only.
ttl Specifies the amount of time before this backup is eligible for garbage collection. Default:720h (equivalent to 30 days). This value is configurable only by the customer.
hooks(Optional) Specifies the actions to perform at different times during a backup. The only supported hook is executing a command in a container in a pod (uses the pod exec API). Supports pre and post hooks.
hooks.resources(Optional) Specifies an array of hooks that are applied to specific resources.
hooks.resources.nameSpecifies the name of the hook. This value displays in the backup log.
hooks.resources.includedNamespaces(Optional) Specifies an array of namespaces that this hook applies to. If unspecified, the hook is applied to all namespaces.
hooks.resources.excludedNamespaces(Optional) Specifies an array of namespaces to which this hook does not apply.
hooks.resources.includedResourcesSpecifies an array of pod resources to which this hook applies.
hooks.resources.excludedResources(Optional) Specifies an array of resources to which this hook does not apply.
hooks.resources.labelSelector(Optional) Specifies that this hook only applies to objects that match this label selector.
hooks.resources.preSpecifies an array of exec hooks to run before executing custom actions.
hooks.resources.postSpecifies an array of exec hooks to run after executing custom actions. Supports the same arrays and fields as pre hooks.
hooks.resources.[post/pre].execSpecifies the type of the hook. exec is the only supported type.
hooks.resources.[post/pre].exec.container(Optional) Specifies the name of the container where the specified command will be executed. If unspecified, the first container in the pod is used.
hooks.resources.[post/pre].exec.commandSpecifies the command to execute. The format is an array.
hooks.resources.[post/pre].exec.onError(Optional) Specifies how to handle an error that might occur when executing the command. Valid values: Fail and Continue Default: Fail
hooks.resources.[post/pre].exec.timeout(Optional) Specifies how many seconds to wait for the command to finish executing before the action times out. Default: 30s

Limitations

  • The following top-level Velero fields, or children of spec, are not supported in full backups:

    • snapshotVolumes
    • volumeSnapshotLocations
    • labelSelector
    • includedResources
    • excludedResources
    note

    Some of these fields are supported for hook arrays, as described in the previous field definition table. See Supported Fields for Full Backups with Snapshots above.

  • All resources are included in the backup by default. However, resources can be excluded by adding velero.io/exclude-from-backup=true to the manifest files that you want to exclude. For more information, see Configuring Snapshots.