Use Velero to Back Up Private Cloud Namespaces

Last modified: October 28, 2024

Introduction

Velero is a tool that you can use to back up your Kubernetes namespaces as an additional disaster recovery measure. It does not back up your database or S3 resources, so it cannot serve as your main backup method, but it can supplement the default backup process for your Mendix app.

Velero enables you to back up and restore the following Mendix objects:

  • storageinstances.privatecloud.mendix.com
  • storageplans.privatecloud.mendix.com
  • builds.privatecloud.mendix.com
  • mendixapps.privatecloud.mendix.com

Prerequisites

Before starting this how-to, make sure you have completed the following prerequisites:

  • Ensure that the Mendix Operator for your private cloud cluster is in version 2.7.0 or above.
  • Install the Velero client and server in version 1.9 or above. For more information, see Velero documentation.
  • Create a recovery cluster.

Creating a Velero Backup

To create a backup with Velero, follow these steps:

  1. Stop the Mendix Operator and Mendix agent by scaling them to 0:

    kubectl scale deployment mendix-agent --replicas=0
    kubectl scale deployment mendix-operator --replicas=0
    
  2. Create the backup by entering the following command:

    velero create backup mendix-velero-bkp
    
  3. Verify that the backup is complete by entering the following command:

    velero backup describe mendix-velero-bkp
    
  4. Restart the Mendix Operator and Mendix agent by entering the following command:

    kubectl scale deployment mendix-agent --replicas=1
    kubectl scale deployment mendix-operator --replicas=1
    

Restoring a Velero Backup

To restore a backup that you created with Velero, follow these steps:

  1. Restore the backup by entering the following command:

    velero restore create --from-backup mendix-velero-bkp --status-include-resources=storageinstances.privatecloud.mendix.com,storageplans.privatecloud.mendix.com,builds.privatecloud.mendix.com,mendixapps.privatecloud.mendix.com
    
  2. After the app has started and created the database, restore a backup of your database and S3 files.

  3. Optional: After restoring the backup, add finalizers to StorageInstances by entering the following command:

    kubectl patch storageinstances $(kubectl get storageinstances --no-headers -o custom-columns=":metadata.name") -p '{"metadata":{"finalizers":["privatecloud.mendix.com/storage-provisioner"]}}' --type=merge