Restore the MongoDB backup data to Common Service DB
Learn how to restore the data that you backed up with MongoDB to the Common Service DB.
This procedure guides you through the restoration of the IM data from MongoDB into Common Service DB.
IBM Cloud Pak foundational services used MongoDB until version 4.4. In IBM Cloud Pak foundational services version 4.5, MongoDB was substituted by the Common Service DB. If your last backup was performed before you upgraded to IBM Cloud Pak foundational services version 4.5 or higher and you need to restore the MongoDB data to Common Service DB, complete the following procedure. This procedure does not affect the condition of Common Service DB, only the old data is migrated.
Scenarios
- The MongoDB resources, such as the operator and statefulSet, are still present, but they are scaled down.
- The MongoDB resources are no longer present.
Before you begin
Before you begin, complete one of the following procedures.
With MongoDB resources still present
-
Run the following command to switch the context to the namespace where Common Service DB is deployed:
oc project <services namespace>
-
Scale down the IM operator pod with the following command:
oc scale deploy ibm-iam-operator --replicas=0
-
Scale up the MongoDB operator:
oc scale deploy ibm-mongodb-operator --replicas=1
-
Wait for the
icp-mongodb-0
pod to be ready.
Without MongoDB resources
-
Run the following command to switch the context to the namespace where Common Service DB is deployed:
oc project <services namespace>
-
Scale down the IM operator pod with the following command:
oc scale deploy ibm-iam-operator --replicas=0
-
Edit
OperandRegistry
.-
Run the following command to edit the
OperandRegistry
:oc edit operandregistry
-
Find the following entry:
- channel: v4.2 installMode: no-op installPlanApproval: Automatic name: ibm-im-mongodb-operator namespace: keycloak-upgrade packageName: ibm-mongodb-operator-app
-
Remove the following line:
installMode: no-op
. -
Create the following
OperandRequest
for MongoDB:- For IBM Cloud Pak foundational services version 4.x:
apiVersion: operator.ibm.com/v1alpha1 kind: OperandRequest metadata: labels: app.kubernetes.io/instance: operand-deployment-lifecycle-manager app.kubernetes.io/managed-by: operand-deployment-lifecycle-manager app.kubernetes.io/name: odlm name: mongodb spec: requests: - operands: - name: ibm-im-mongodb-operator registry: common-service
- For IBM Cloud Pak foundational services version 3.19.x and 3.23.x:
apiVersion: operator.ibm.com/v1alpha1 kind: OperandRequest metadata: labels: app.kubernetes.io/instance: operand-deployment-lifecycle-manager app.kubernetes.io/managed-by: operand-deployment-lifecycle-manager app.kubernetes.io/name: odlm name: mongodb spec: requests: - operands: - name: ibm-mongodb-operator registry: common-service
-
-
Wait for the
icp-mongodb-0
pod to be ready.
Procedure
-
Restore the MongoDB data. For more information, see Set the Common Service DB data to the desired state.
-
Delete the EDB cluster Custom Resource (CR):
Note: Delete the EDB cluster deletes all data that is stored in Common Service DB. Consider backing up Common Service DB first.
oc delete clusters.postgresql.k8s.enterprisedb.io common-service-db
-
Wait for Common Service DB resources to delete. It can take a few minutes.
- Wait for Operator Deployment Lifecycle Manager (ODLM) to recreate the EDB cluster CR. You can start this process by deleting the
operand-deployment-lifecycle-management
pod in the operator namespace. - Wait for the EDB resources to be set up properly. It can take up to ten minutes and must be done successfully to proceed.
-
Edit the Authentication CR to set the migration annotation to
"false"
:oc patch authentications.operator.ibm.com example-authentication --type='merge' -p '{"metadata":{"annotations":{"authentication.operator.ibm.com/migration-complete":"false"}}}'
-
Scale the IM operator up:
oc scale deploy ibm-iam-operator --replicas=1
Wait for the migration to complete. When the migration is complete, the migration annotation becomes set to
"true"
. You can track the logs in the IM operator by searching for themigration_worker
phrase.
Note: If Zen is present, make sure to rollback the Zen data to the same level to prevent the problems with data sync. To sync the Zen data, complete the following procedure: Set the Zen 5 data to the desired state.