Steps to take a Backup from cStor for Replicated DB (Mongo)
note
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 ClusterCurrently, we have a cStor cluster as the source, with a clustered MongoDB running as a StatefulSet using cStor volumes.
Command
Output
Command
Output
Command
Output
#
Step 2: Install Veleroinfo
For the prerequisites, see to the overview section.
Run the following command to install Velero:
Command
Output
Verify the Velero namespace for Node Agent and Velero pods:
Command
Output
#
Step 3: Data ValidationOn 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 BackupMongoDB 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:
- Opt-in approach: Annotate pods containing volumes to be backed up.
- Opt-out approach: Backup all pod volumes with the ability to opt-out specific volumes.
#
Opt-In for Primary MongoDB PodTo 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:
#
Opt-Out for Secondary MongoDB Pods and PVCsTo exclude secondary MongoDB pods and their associated Persistent Volume Claims (PVCs) from the backup, we can label them as follows:
#
Backup ExecutionCreate 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:
Command
Output
#
Backup VerificationTo 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:
Command
Output