This guide will show you how Stash backs up and restores volumes of various workload types (Deployment, StatefulSet, DaemonSet etc.).
Stash
concepts:
The following diagram shows how Stash takes backup of the volumes of a workload. Open the image in a new tab to see the enlarged version.
The backup process consists of the following steps:
At first, a user creates a Secret. This secret holds the credentials to access the backend where the backed up data will be stored.
Then, she creates a Repository
crd which represents the original repository in the backend.
Then, she creates a BackupConfiguration
crd which specifies the targeted workload and desired file paths to backup. It also specifies the Repository
object that holds the backend information where the backed up data will be stored.
Stash operator watches for BackupConfiguration
objects.
When it finds a BackupConfiguration
object, it finds the targeted workload and injects a sidecar named stash
.
It also creates a CronJob
to trigger backups periodically.
TheCronJob
triggers backup on each scheduled slot by creating a BackupSession
crd.
The stash
sidecar inside the workload watches for BackupSession
crd.
When it finds a BackupSession
crd, it initiates backup of the targeted file paths.
Once the backup process is completed, the sidecar
sends Prometheus metrics to the Pushgateway running inside the stash-operator
pod. It also updates respective BackupSession
and Repository
status to reflect the backup process.
The following diagram shows how Stash restores backed up data inside a workload. Open the image in a new tab to see the enlarged version.
The restore process consists of the following steps:
At first, the user creates a workload where the data will be restored.
Then, she creates a RestoreSession
crd that specifies the targeted workload where the backed up data will be restored. It also specifies the respective Repository
that holds the respective backend information.
Stash operator watches for RestoreSession
crds.
When it finds a RestoreSession
crd, it injects an init-container named stash-init
to the workload and restart it.
The init-container restores the desired data from the backend on start-up.
Finally, when the restore process is completed it sends Prometheus metrics to the pushgateway
running inside the stash operator. It also update the RestoreSession
status to reflect the restore process.
Note: If your workload restarts with the
stash-init
init-container for any reason, the init-container will skip running restore process if there is no pendingRestoreSession
for this workload.