Skip to main content
Version: Stable

Backup

Follow this guide to create backup for Elemental configuration installed together with Rancher.

Install rancher-backup operator for Rancher

Go to official Rancher documentation and install rancher-bakup operator from there.

warning

For Rancher v2.7 and below it is needed to edit ResourceSet for rancher-backup operator. For Rancher v2.7.1+ backup will be done automatically by rancher-backup operator and no further operation are needed.

Backup Elemental with rancher-backup operator (only for Rancher v2.7 and below)

Fetch rancher-resource-set object from Kubernetes cluster

kubectl get ResourceSet rancher-resource-set -o yaml > rancher-resource-set.yaml

At the end of rancher-resource-set.yaml file add the definition of Elemental resources

- apiVersion: apiextensions.k8s.io/v1
kindsRegexp: .
resourceNameRegexp: elemental.cattle.io$
- apiVersion: apps/v1
kindsRegexp: ^deployments$
namespaces:
- cattle-elemental-system
resourceNames:
- elemental-operator
- apiVersion: rbac.authorization.k8s.io/v1
kindsRegexp: ^clusterroles$
resourceNames:
- elemental-operator
- apiVersion: rbac.authorization.k8s.io/v1
kindsRegexp: ^clusterrolebindings$
resourceNames:
- elemental-operator
- apiVersion: v1
kindsRegexp: ^serviceaccounts$
namespaces:
- cattle-elemental-system
resourceNames:
- elemental-operator
- apiVersion: management.cattle.io/v3
kindsRegexp: ^globalrole$
resourceNames:
- elemental-operator
- apiVersion: management.cattle.io/v3
kindsRegexp: ^apiservice$
resourceNameRegexp: elemental.cattle.io$
- apiVersion: elemental.cattle.io/v1beta1
kindsRegexp: .
namespaceRegexp: ^cattle-fleet-|^fleet-|^cluster-fleet-
- apiVersion: rbac.authorization.k8s.io/v1
kindsRegexp: ^roles$|^rolebindings$
labelSelectors:
matchExpressions:
- key: elemental.cattle.io/managed
operator: In
values:
- "true"
namespaceRegexp: ^cattle-fleet-|^fleet-|^cluster-fleet-
- apiVersion: v1
kindsRegexp: ^secrets$|^serviceaccounts$
labelSelectors:
matchExpressions:
- key: elemental.cattle.io/managed
operator: In
values:
- "true"
namespaceRegexp: ^cattle-fleet-|^fleet-|^cluster-fleet-

Then apply changes to Kubernetes cluster

kubectl apply -f rancher-resource-set.yaml

Create backup with creating Backup object

apiVersion: resources.cattle.io/v1
kind: Backup
metadata:
name: elemental-backup
spec:
resourceSetName: rancher-resource-set
schedule: "10 3 * * *"
retentionCount: 10

Check logs from rancher-backup operator

kubectl logs -n cattle-resources-system -l app.kubernetes.io/name=rancher-backup -f

Verify if backup file was created on Persistent Volume.

...
INFO[2022/10/17 07:45:04] Finding files starting with /var/lib/backups/rancher-backup-430169aa-edde-4a61-85e8-858f625a755b*.tar.gz
INFO[2022/10/17 07:45:04] File rancher-backup-430169aa-edde-4a61-85e8-858f625a755b-2022-10-17T05-15-00Z.tar.gz was created at 2022-10-17 0
...