Steps to Restore from cStor Backup to Replicated Storage for Replicated DBs (Mongo)
info
Before you begin, make sure you have the following:
- Access to a Kubernetes cluster with Velero installed.
- A backup of your Mongo database created using Velero.
- Replicated Storage (a.k.a Replicated Engine or Mayastor) configured in your Kubernetes environment.
#
Step 1: Install Velero with GCP Provider on Destination (Replicated Storage Cluster)Install Velero with the GCP provider, ensuring you use the same values for the BUCKET-NAME
and SECRET-FILENAME
placeholders that you used originally. These placeholders should be replaced with your specific values:
Command
Output
#
Step 2: Verify Backup AvailabilityCheck the availability of your previously-saved backups. If the credentials or bucket information does not match, the backups cannot be seen:
Command
Output
Command
Output
#
Step 3: Restore Using Velero CLIInitiate the restore process using Velero CLI with the following command:
Command
Output
#
Step 4: Check Restore StatusYou can check the status of the restore process by using the velero get restore
command.
When Velero performs a restore, it deploys an init container within the application pod, responsible for restoring the volume. Initially, the restore status will be InProgress
.
note
Your storage class was originally set to cstor-csi-disk
because you imported this PVC from a cStor volume, the status might temporarily stay as In Progress and your PVC will be in Pending status.
#
Step 5: Backup PVC and Change Storage Class- Retrieve the current configuration of the PVC which is in
Pending
status using the following command:
- Confirm that the PVC configuration has been saved by checking its existence with this command:
- Edit the
pvc-mongo.yaml
file to update its storage class. Below is the modified PVC configuration withmayastor-single-replica
set as the new storage class:
note
The statefulset for Mongo will still have the cstor-csi-disk
storage class at this point. This will be addressed in the further steps.
#
Step 6: Resolve Issue where PVC is Pending- Begin by deleting the problematic PVC with the following command:
- Once the PVC has been successfully deleted, you can recreate it using the updated configuration from the
pvc-mongo.yaml
file. Apply the new configuration with the following command:
#
Step 7: Check Velero Init ContainerAfter recreating the PVC with Mayastor storageClass, you will observe the presence of a Velero initialization container within the application pod. This container is responsible for restoring the required volumes.
You can check the status of the restore operation by running the following command:
The output will display the pods' status, including the Velero initialization container. Initially, the status might show as "Init:0/1," indicating that the restore process is in progress.
You can track the progress of the restore by running:
Command
Output
You can then verify the data restoration by accessing your MongoDB instance. In the provided example, we used the "mongosh" shell to connect to the MongoDB instance and check the databases and their content. The data should reflect what was previously backed up from the cStor storage.
#
Step 8: Monitor Pod ProgressDue to the statefulset's configuration with three replicas, you will notice that the mongo-1
pod is created but remains in a Pending
status. This behavior is expected as we have the storage class set to cStor in statefulset configuration.
#
Step 9: Capture the StatefulSet Configuration and Modify Storage ClassCapture the current configuration of the StatefulSet for MongoDB by running the following command:
This command will save the existing StatefulSet configuration to a file named sts-mongo-original.yaml
. Next, edit this YAML file to change the storage class to mayastor-single-replica
.
#
Step 10: Delete StatefulSet (Cascade=False)Delete the StatefulSet while preserving the pods with the following command:
You can run the following commands to verify the status:
#
Step 11: Deleting Pending Secondary Pods and PVCsDelete the MongoDB Pod mongod-1
.
Delete the Persistent Volume Claim (PVC) for mongod-1
.
#
Step 12: Recreate StatefulSetRecreate the StatefulSet with the Yaml file.
Command
Output
Command
Output
Command
Output
#
Step 13: Verify Data Replication on Secondary DBVerify data replication on the secondary database to ensure synchronization.