Backup from cStor

If you are deploying databases using operators, you need to find a way to actively modify the entire deployment through the operator. This ensures that you control and manage changes effectively within the operator-driven database deployment.

Step 1: Backup from cStor Cluster

Currently, we have a cStor cluster as the source, with a clustered MongoDB running as a StatefulSet using cStor volumes.

kubectl get pods
kubectl get pvc
kubectl get cvc -n openebs

Step 2: Install Velero

For the prerequisites, refer to the overview section.

Run the following command to install Velero:

velero install --use-node-agent --provider gcp --plugins velero/velero-plugin-for-gcp:v1.6.0 --bucket velero-backup-datacore --secret-file ./credentials-velero --uploader-type restic

Verify the Velero namespace for Node Agent and Velero pods:

kubectl get pods -n velero

Step 3: Data Validation

On the Primary Database (mongo-0) you can see some sample data.

You can also see the data available on the replicated secondary databases.

Step 4: Take Velero Backup

MongoDB uses replication, and data partitioning (sharding) for high availability and scalability. Taking a backup of the primary database is enough as the data gets replicated to the secondary databases. Restoring both primary and secondary at the same time can cause data corruption.

For reference: MongoDB Backup and Restore Error Using Velero

Velero supports two approaches for discovering pod volumes to be backed up using FSB:

  1. Opt-in approach: Annotate pods containing volumes to be backed up.

  2. Opt-out approach: Backup all pod volumes with the ability to opt-out specific volumes.

Opt-In for Primary MongoDB Pod:

To ensure that our primary MongoDB pod, which receives writes and replicates data to secondary pods, is included in the backup, we need to annotate it as follows:

kubectl annotate pod/mongod-0

Opt-Out for Secondary MongoDB Pods and PVCs:

To exclude secondary MongoDB pods and their associated Persistent Volume Claims (PVCs) from the backup, we can label them as follows:

kubectl label pod mongod-1
pod/mongod-1 labeled
kubectl label pod mongod-2
pod/mongod-2 labeled
kubectl label pvc mongodb-persistent-storage-claim-mongod-1
persistentvolumeclaim/mongodb-persistent-storage-claim-mongod-1 labeled
kubectl label pvc mongodb-persistent-storage-claim-mongod-2
persistentvolumeclaim/mongodb-persistent-storage-claim-mongod-2 labeled

Backup Execution:

Create a backup of the entire namespace. If any other applications run in the same namespace as MongoDB, we can exclude them from the backup using labels or flags from the Velero CLI:

velero backup create mongo-backup-13-09-23 --include-namespaces default --default-volumes-to-fs-backup --wait

Backup Verification:

To check the status of the backup using the Velero CLI, you can use the following command. If the backup fails for any reason, you can inspect the logs with the velero backup logs command:

velero get backup | grep 13-09-23

Last updated