Logical MongoDB Backup

If it hasn't been done already, the bitnami Helm repository needs to be added to your local configuration:

# Add bitnami helm repo
$ helm repo add bitnami https://charts.bitnami.com/bitnami

Install the MongoDB chart from the bitnami Helm repository:

$ kubectl create namespace mongodb-logical
$ helm install mongo-logical bitnami/mongodb --namespace mongodb-logical \
    --set architecture="replicaset"

To create a Blueprint resource, please run the command below:

 $ curl https://raw.githubusercontent.com/kanisterio/kanister/0.107.0/examples/mongodb/blueprint-v2/mongo-blueprint.yaml > mongo-blueprint.yaml
 $ kubectl apply -f mongo-blueprint.yaml --namespace kasten-io

Note

The MongoDB backup example above serves as a blueprint template for logical backups. Please note that these examples may need to be modified for specific production environments and setups. As a result, it is highly recommended to carefully review and modify the blueprints as needed before deploying them for production use.

Alternatively, use the Blueprints page on K10 Dashboard to create the Blueprint resource.

Note

If MongoDB chart is installed specifying existing secret by setting parameter --set auth.existingSecret=<mongo-secret-name>, secret name in the blueprint mongo-blueprint.yaml needs to be modified at following places:

actions.backup.phases[0].objects.mongosecret.name: <mongo-secret-name> actions.restore.phases[0].objects.mongosecret.name: <mongo-secret-name>

Once the Blueprint is created, we will have to annotate the StatefulSet with the correct annotation to instruct K10 to use the Blueprint while performing operations on this MongoDB instance. The following example demonstrates how to annotate the MongoDB StatefulSet with the mongodb-logical Blueprint.

$ kubectl annotate statefulset mongo-logical-mongodb kanister.kasten.io/blueprint='mongodb-blueprint' \
      --namespace=mongodb-logical

Finally, use K10 to backup and restore the application.