Skip to main content

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/v1kindsRegexp: .resourceNameRegexp: elemental.cattle.io$- apiVersion: apps/v1kindsRegexp: ^deployments$namespaces:- cattle-elemental-systemresourceNames:- elemental-operator- apiVersion: rbac.authorization.k8s.io/v1kindsRegexp: ^clusterroles$resourceNames:- elemental-operator- apiVersion: rbac.authorization.k8s.io/v1kindsRegexp: ^clusterrolebindings$resourceNames:- elemental-operator- apiVersion: v1kindsRegexp: ^serviceaccounts$namespaces:- cattle-elemental-systemresourceNames:- elemental-operator- apiVersion: management.cattle.io/v3kindsRegexp: ^globalrole$resourceNames:- elemental-operator- apiVersion: management.cattle.io/v3kindsRegexp: ^apiservice$resourceNameRegexp: elemental.cattle.io$- apiVersion: elemental.cattle.io/v1beta1kindsRegexp: .namespaceRegexp: ^cattle-fleet-|^fleet-|^cluster-fleet-- apiVersion: rbac.authorization.k8s.io/v1kindsRegexp: ^roles$|^rolebindings$labelSelectors:  matchExpressions:  - key: elemental.cattle.io/managed    operator: In    values:    - "true"namespaceRegexp: ^cattle-fleet-|^fleet-|^cluster-fleet-- apiVersion: v1kindsRegexp: ^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 elemental-backup.yaml file which allows backup with creating Backup object

apiVersion: resources.cattle.io/v1kind: Backupmetadata:  name: elemental-backupspec:  resourceSetName: rancher-resource-set  schedule: "10 3 * * *"  retentionCount: 10

Then apply changes to Kubernetes cluster

kubectl apply -f elemental-backup.yaml

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...