In this section, you’ll learn how to back up Rancher running on any Kubernetes cluster. To backup Rancher installed with Docker, refer the instructions for single node backups

The backup-restore operator needs to be installed in the local cluster, and only backs up the Rancher app. The backup and restore operations are performed only in the local Kubernetes cluster.

Prerequisites

Rancher version must be v2.5.0 and up

1. Install the rancher-backup operator

The backup storage location is an operator-level setting, so it needs to be configured when rancher-backup is installed or upgraded.

Backups are created as .tar.gz files. These files can be pushed to S3 or Minio, or they can be stored in a persistent volume.

  1. In the Rancher UI, go to the Cluster Explorer view for the local cluster.
  2. Click Apps.
  3. Click Rancher Backups.
  4. Configure the default storage location. For help, refer to the storage configuration section.

2. Perform a Backup

To perform a backup, a custom resource of type Backup must be created.

  1. In the Cluster Explorer, go to the dropdown menu in the upper left corner and click Rancher Backups.
  2. Click Backup.
  3. Create the Backup with the form, or with the YAML editor.
  4. For configuring the Backup details using the form, click Create and refer to the configuration reference and to the examples.
  5. For using the YAML editor, we can click Create > Create from YAML. Enter the Backup YAML. This example Backup custom resource would create encrypted recurring backups in S3. The app uses the credentialSecretNamespace value to determine where to look for the S3 backup secret:

    1. apiVersion: resources.cattle.io/v1
    2. kind: Backup
    3. metadata:
    4. name: s3-recurring-backup
    5. spec:
    6. storageLocation:
    7. s3:
    8. credentialSecretName: s3-creds
    9. credentialSecretNamespace: default
    10. bucketName: rancher-backups
    11. folder: rancher
    12. region: us-west-2
    13. endpoint: s3.us-west-2.amazonaws.com
    14. resourceSetName: rancher-resource-set
    15. encryptionConfigSecretName: encryptionconfig
    16. schedule: "@every 1h"
    17. retentionCount: 10

    Note: When creating the Backup resource using YAML editor, the resourceSetName must be set to rancher-resource-set

    For help configuring the Backup, refer to the configuration reference and to the examples.

    Important: The rancher-backup operator doesn’t save the EncryptionConfiguration file. The contents of the EncryptionConfiguration file must be saved when an encrypted backup is created, and the same file must be used when restoring from this backup.

  6. Click Create.

Result: The backup file is created in the storage location configured in the Backup custom resource. The name of this file is used when performing a restore.