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.
This tutorial will show you how to restore a Stash backup. At first, backup a kubernetes workload volume by following the steps here.
To restore a backup, you need to create a
Recovery CRD by specifying
Restic, target workload and volume where backup will be restored.
$ kubectl apply -f ./docs/examples/tutorial/recovery.yaml recovery "stash-demo" created
apiVersion: stash.appscode.com/v1alpha1 kind: Recovery metadata: name: stash-demo namespace: default spec: workload: kind: Deployment name: stash-demo backend: local: mountPath: /safe/data hostPath: path: /data/stash-test/restic-repo storageSecretName: stash-demo paths: - /source/data recoveredVolumes: - mountPath: /source/data hostPath: path: /data/stash-test/restic-restored
spec.workloadspecifies a target workload that was backed up using
Restic. A single
Resticbackups all types of workloads that matches the label-selector, but you can only restore a specific workload using a
Statefulset, you need to specify pod index using
Daemonset, you need to specify node name using
spec.backendspecifies the backend that was used in
Resticto take backups.
spec.pathsspecifies the file-group paths that was backed up using
spec.recoveredVolumesindicates an array of volumes where snapshots will be recovered. Here,
mountPathspecifies where the volume will be mounted. Note that,
Recoveryrecovers data in the same paths from where backup was taken (specified in
spec.paths). So, volumes must be mounted on those paths or their parent paths.
Stash operator watches for
Recovery objects using Kubernetes api. It collects required snapshot information from the specified
Restic object. Then it creates a recovery job that performs the recovery guides. On completion, job and associated pods are deleted by stash operator. To verify recovery, we can check the
$ kubectl get recovery stash-demo -o yaml apiVersion: stash.appscode.com/v1alpha1 kind: Recovery metadata: clusterName: "" creationTimestamp: 2017-12-04T06:27:16Z deletionGracePeriodSeconds: null deletionTimestamp: null generation: 0 initializers: null name: stash-demo namespace: default resourceVersion: "29671" selfLink: /apis/stash.appscode.com/v1alpha1/namespaces/default/recoveries/stash-demo uid: 2bf74432-d8bc-11e7-be92-0800277f19c0 spec: workload: kind: Deployment name: stash-demo backend: local: mountPath: /safe/data hostPath: path: /data/stash-test/restic-repo storageSecretName: stash-demo paths: - /source/data recoveredVolumes: - mountPath: /source/data hostPath: path: /data/stash-test/restic-restored status: phase: Succeeded
To cleanup the Kubernetes resources created by this tutorial, run:
$ kubectl delete deployment stash-demo $ kubectl delete secret stash-demo $ kubectl delete restic stash-demo $ kubectl delete recovery stash-demo
If you would like to uninstall Stash operator, please follow the steps here.