|
| 1 | +--- |
| 2 | +sidebar_label: Rancher Backup Operator |
| 3 | +sidebar_position: 140 |
| 4 | +title: Backup and restore with Rancher Backup Operator |
| 5 | +description: Backup and restore with Rancher Backup Operator |
| 6 | +keywords: [kubernetes, kubewarden, rancher backup operator, backup, restore] |
| 7 | +doc-persona: [kubewarden-operator, kubewarden-integrator] |
| 8 | +doc-type: [howto] |
| 9 | +doc-topic: [operator-manual, rancher-backup-operator] |
| 10 | +--- |
| 11 | + |
| 12 | +<head> |
| 13 | + <link rel="canonical" href="https://docs.kubewarden.io/howtos/Rancher-Backup-Operator"/> |
| 14 | +</head> |
| 15 | + |
| 16 | +The `rancher-backup` operator can be used to backup and restore Rancher on any |
| 17 | +Kubernetes cluster. |
| 18 | + |
| 19 | +Since version X.Y.Z, `rancher-backup` has support for Kubewarden. This includes: |
| 20 | + |
| 21 | +- the default Rancher Namespace `catttle-kubewarden-system` (or |
| 22 | + `cattle-kubewarden-*`), and the default Kubewarden Namespace `kubewarden`. |
| 23 | +- Kubewarden needed resources installed via the Helm charts. |
| 24 | +- Kubewarden CRDs, which get reconciled after restore by the Kubewarden controller. |
| 25 | +- The `policy-reporter` subchart of the `kubewarden-controller` chart, for their |
| 26 | + default values. This doesn't include the Grafana integration nor other plugins. |
| 27 | + |
| 28 | +The backup process doesn't include Secrets created to [configure PolicyServers |
| 29 | +for private registries](,/policy-servers/private-registry#creating-the-secret) |
| 30 | +unless those are correctly labeled. |
| 31 | + |
| 32 | +## Installing Rancher Backup Operator |
| 33 | + |
| 34 | +Follow the [Rancher |
| 35 | +documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/backup-restore-and-disaster-recovery). |
| 36 | +For a Minikube install using the PersistentVolumes of type `hostPath` named |
| 37 | +`standard` that Minikube supports out of the box, the installation would be as |
| 38 | +follows: |
| 39 | + |
| 40 | +```console |
| 41 | +$ helm repo add rancher-charts https://charts.rancher.io |
| 42 | +$ helm repo update |
| 43 | +$ helm install --wait --create-namespace -n cattle-resources-system \ |
| 44 | + rancher-backup-crd rancher-charts/rancher-backup-crd |
| 45 | +$ helm install --wait -n cattle-resources-system \ |
| 46 | + rancher-backup rancher-charts/rancher-backup \ |
| 47 | + --set persistence.enabled=true --set persistence.storageClass=standard |
| 48 | +``` |
| 49 | + |
| 50 | +## Backup |
| 51 | + |
| 52 | +Use the `rancher-resource-set-full` to backup the Kubewarden Secrets. These |
| 53 | +include the TLS Secrets that get created on Helm installation. |
| 54 | + |
| 55 | +If you prefer the use `rancher-resource-basic`, please remember to backup or |
| 56 | +manually create needed TLS Secrets. |
| 57 | + |
| 58 | +Here is an example of performing an unencrypted backup to the default location |
| 59 | +with the `rancher-resource-set-full`: |
| 60 | + |
| 61 | +```shell |
| 62 | +$ kubectl apply -f - <<EOF |
| 63 | +apiVersion: resources.cattle.io/v1 |
| 64 | +kind: Backup |
| 65 | +metadata: |
| 66 | + name: default-location-backup |
| 67 | +spec: |
| 68 | + resourceSetName: rancher-resource-set-full |
| 69 | +EOF |
| 70 | +backup.resources.cattle.io/default-location-backup created |
| 71 | +``` |
| 72 | + |
| 73 | +The `rancher-backup` logs will show the creation of the backup file. Take note |
| 74 | +of the filename: |
| 75 | + |
| 76 | +``` |
| 77 | +$ kubectl logs -n cattle-resources-system -l app.kubernetes.io/name=rancher-backup -f |
| 78 | +... |
| 79 | +INFO[2025/06/26 10:07:48] Processing backup default-location-backup |
| 80 | +INFO[2025/06/26 10:07:48] For backup CR default-location-backup, filename: default-location-backup-32d64f39-d3c7-4331-9101-8ca493bd9d2e-2025-06-26T10-07-48Z |
| 81 | +... |
| 82 | +INFO[2025/06/26 10:07:49] Done with backup |
| 83 | +``` |
| 84 | + |
| 85 | +See the Rancher docs for more [backup examples](https://ranchermanager.docs.rancher.com/reference-guides/backup-restore-configuration/examples#backup). |
| 86 | + |
| 87 | +## Restore |
| 88 | + |
| 89 | +To restore the unencrypted backup from the default location, take the filename |
| 90 | +and append `.tar.gz` when creating the Restore Custom Resource: |
| 91 | + |
| 92 | +```shell |
| 93 | +$ kubectl apply -f - <<EOF |
| 94 | +apiVersion: resources.cattle.io/v1 |
| 95 | +kind: Restore |
| 96 | +metadata: |
| 97 | + name: restore-default |
| 98 | +spec: |
| 99 | + backupFilename: default-location-backup-32d64f39-d3c7-4331-9101-8ca493bd9d2e-2025-06-26T10-07-48Z.tar.gz |
| 100 | +EOF |
| 101 | +restore.resources.cattle.io/restore-default created |
| 102 | + |
| 103 | +$ kubectl logs -n cattle-resources-system -l app.kubernetes.io/name=rancher-backup -f |
| 104 | +... |
| 105 | +INFO[2025/06/26 10:9:03] Done restoring |
| 106 | +``` |
| 107 | + |
| 108 | +See the Rancher docs for more [restore examples](https://ranchermanager.docs.rancher.com/reference-guides/backup-restore-configuration/examples#restore). |
0 commit comments