You are looking at the documentation of a prior release. To read the documentation of the latest release, please visit here.
New to Stash? Please start here.
BackupConfiguration is a Kubernetes
CustomResourceDefinition(CRD) which specifies the backup target, parameters(schedule, retention policy etc.) and a
Repository object that holds snapshot storage information in a Kubernetes native way.
You have to create a
BackupConfiguration object for each backup target. A backup target can be a workload, database or a PV/PVC.
Like any official Kubernetes resource, a
Spec sections. However, unlike other Kubernetes resources, it does not have a
BackupConfiguration object to backup the volumes of a Deployment is shown below:
# name: workload-backup # task field is not required for workload data backup but it is necessary for database backup.
schedule: "* * * * *" # backup at every minutes
- name: source-data
- echo "Sample PreBackup hook demo"
- echo "Sample PostBackup hook demo"
- name: my-private-registry-secret
Here, we are going to describe the various sections of
BackupConfiguration object has the following fields in the
spec.driver indicates the mechanism used to backup a target. Currently, Stash supports
VolumeSnapshotter as drivers. The default value of this field is
|Used to backup workload data, persistent volumes data and databases. It uses restic to backup the target.
|Used to take snapshot of PersistentVolumeClaims of a targeted workload. It leverages Kubernetes VolumeSnapshot crd and CSI driver to snapshot the PVCs.
spec.target field indicates the target for backup runs. This field consists of the following sub-fields:
spec.target.alias : The alias is used as an identifer of the backed up data in the backend. This is particularly useful for
BackupBatch where multiple targets are backed up into a single repository.
spec.target.ref refers to the target of backup. You have to specify
name of the target. Stash will use this information to inject a sidecar to the target or to create a backup job for it.
spec.target.paths specifies list of file paths to backup.
spec.target.exclude : Specifies a list of pattern for the files that should be ignored during backup. Stash will not backup the files that matches these patterns.
spec.target.volumeMounts are the list of volumes and their
mountPaths that contain the target file paths. Stash will mount these volumes inside a sidecar container or a backup job.
spec.target.snapshotClassName indicates the VolumeSnapshotClass to use for volume snasphotting. Use this field only if
spec.driver is set to
spec.repository.name indicates the
Repository crd name that holds necessary backend information where the backed up data will be stored.
spec.backupHistoryLimit specifies the number of
BackupSession and its associate resources (Job, PVC etc.) to keep for debugging purposes. The default value of this field is 1. Stash will cleanup the old
BackupSession and it’s associate resources after each backup session according to
spec.task specifies the name and parameters of the Task crd to use to backup the target.
spec.task.name indicates the name of the
Task to use for this backup process.
spec.task.params is an array of custom parameters to use to configure the task.
spec.tasksection is not required for backing up workload data (i.e. Deployment, DaemonSet, StatefulSet etc.). However, it is necessary for backing up databases and stand-alone PVCs.
spec.paused can be used as
enable/disable switch for backup. If it is set
true, Stash will not take any backup of the target specified by this BackupConfiguration.
spec.hooks allows performing some actions before and after the backup process. You can send HTTP requests to a remote server via
httpPost hooks. You can check whether a TCP socket is open using
tcpSocket hook. You can also execute some commands into your application pod using
spec.hooks.preBackup hooks are executed before the backup process.
spec.hooks.postBackup hooks are executed after the backup process.
For more details on how hooks work in Stash and how to configure different types of hook, please visit here.
spec.runtimeSettings allows to configure runtime environment for the backup sidecar or job. You can specify runtime settings at both pod level and container level.
spec.runtimeSettings.container is used to configure the backup sidecar/job at container level. You can configure the following container level parameters:
|Compute resources required by the sidecar container or backup job. To learn how to manage resources for containers, please visit here.
|Periodic probe of backup sidecar/job container’s liveness. Container will be restarted if the probe fails.
|Periodic probe of backup sidecar/job container’s readiness. Container will be removed from service endpoints if the probe fails.
|Actions that the management system should take in response to container lifecycle events.
|Security options that backup sidecar/job’s container should run with. For more details, please visit here.
|Set CPU scheduling priority for backup process. For more details about
nice, please visit here.
|Set I/O scheduling class and priority for backup process. For more details about
ionice, please visit here.
|A list of the environment variables to set in the sidecar container or backup job’s container.
|This allows to set environment variables to the container that will be created for this function from a Secret or ConfigMap.
spec.runtimeSettings.pod is used to configure backup job in pod level. You can configure the following pod level parameters,
|Name of the
ServiceAccount to use for the backup job. Stash sidecar will use the same
ServiceAccount as the target workload.
|Selector which must be true for backup job pod to fit on a node.
|Indicates whether a service account token should be automatically mounted into the backup pod.
nodeName is used to request to schedule backup job’s pod onto a specific node.
|Security options that backup job’s pod should run with. For more details, please visit here.
|A list of secret names in the same namespace that will be used to pull image from private Docker registry. For more details, please visit here.
|Affinity and anti-affinity to schedule backup job’s pod on a desired node. For more details, please visit here.
|Name of the scheduler that should dispatch the backup job.
|Taints and Tolerations to ensure that backup job’s pod is not scheduled in inappropriate nodes. For more details about
toleration, please visit here.
|Indicates the backup job pod’s priority class. For more details, please visit here.
|Indicates the backup job pod’s priority value.
|Specifies additional conditions to be evaluated for Pod readiness. For more details, please visit here.
|RuntimeClass is used for selecting the container runtime configuration. For more details, please visit here
|EnableServiceLinks indicates whether information about services should be injected into pod’s environment variables.
Stash mounts an
emptyDir for holding temporary files. It is also used for
caching for faster backup performance. You can configure the
spec.tempDir section. You can also disable
caching using this field. The following fields are configurable in
false by default.
For some targets (i.e. some databases), Stash can’t directly pipe the dumped data to the uploading process. In this case, it has to store the dumped data temporarily before uploading to the backend.
spec.interimVolumeTemplate specifies a PVC template for holding those data temporarily. Stash will create a PVC according to the template and use it to store the data temporarily. This PVC will be deleted according to the spec.backupHistoryLimit.
Note that the usage of this field is different than
spec.tempDirwhich is used for caching purpose. Stash has introduced this field because the
emptyDirvolume that is used for
spec.tempDirdoes not play nice with large databases( i.e. 100Gi database). Also, it provides debugging capability as Stash keeps it until it hits the limit specified in
spec.retentionPolicy specifies the policy to follow for cleaning old snapshots. Following options are available to configure retention policy:
restic forget command flag
|Name of retention policy. You can provide any name.
|Never delete the n last (most recent) snapshots.
|For the last n hours in which a snapshot was made, keep only the last snapshot for each hour.
|For the last n days which have one or more snapshots, only keep the last one for that day.
|For the last n weeks which have one or more snapshots, only keep the last one for that week.
|For the last n months which have one or more snapshots, only keep the last one for that month.
|For the last n years which have one or more snapshots, only keep the last one for that year.
|Keep all snapshots which have all tags specified by this option (can be specified multiple times).
true, Stash will cleanup unreferenced data from the backend.
|Stash will not remove anything but print which snapshots would be removed.
BackupConfiguration object has the following fields in the
observedGeneration : The most recent generation observed by the
conditions : The
spec.conditions shows current backup setup condition for this BackupConfiguration. The following conditions are set by the Stash operator:
|Indicates whether the respective Repository object was found or not.
|Indicates whether the respective backend secret was found or not.
|Indicates whether the backup triggering CronJob was created or not.