Logical MongoDB BackupΒΆ

Install the MongoDB chart from the stable Helm repository:

$ helm install stable/mongodb --name mongo-logical --namespace mongodb-logical \
    --set replicaSet.enabled=true
$ kubectl create namespace mongodb-logical
$ helm install mongo-logical stable/mongodb --namespace mongodb-logical \
    --set replicaSet.enabled=true


We create two Blueprints here because the backup of the MongoDB is completed from primary MongoDB pod itself, we will not have to do any backup related activities in the secondary MongoDB pods. We therefore create a noop BluePrint and annotate secondary MongoDB StatefulSet to use the noop Blueprint.

To create a Blueprint resource, please run below command:

$ kubectl --namespace kasten-io apply -f \

To create another Blueprint resource, create a file named mongo_noop_logical.yaml with following contents:

apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
  name: mongo-noop
    type: StatefulSet
    - func: KubeExec
      name: lockMongo
        namespace: "{{ .StatefulSet.Namespace }}"
        pod: "{{ index .StatefulSet.Pods 0 }}"
        container: mongodb-secondary
        - echo
        - NOOP

and then apply the Blueprint using below command

$ kubectl --namespace=kasten-io create -f mongo_noop_logical.yaml

Once the Blueprint is created we will have to annotate the StatefulSets with the correct annotations to instruct K10 to use the Blueprint while performing operations on this MongoDB instance. We annotate the primary StatefulSet with the Blueprint named mongodb-logical but the secondary one with Blueprint mongo-noop to avoid taking any action on the secondary members.

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

Finally, use K10 to backup and restore the application.