By default, backing up data is disabled for the MongoDB
Ops Manager.
Before you begin
Create a MongoDB
Ops Manager instance that meets the following
configuration
requirements:Number of replicas: 3
Number of cores: 4
Memory: 8 GiB
Storage size: 64 GiB
The
following example is a custom resource that meets the minimum requirements for backup and restore.
apiVersion: mongodb.cpd.ibm.com/v1
kind: CPDMongoDBOpsManager
metadata:
name: ${OPS_MANAGER_INSTANCE_NAME}
spec:
license:
accept: true
version: 4.0.0
dedicated: false
replicas: 2
storageSize: "64G"
storageClass: ${STG_CLASS_BLOCK}
resources:
requests:
cpu: "4"
memory: "8G"
limits:
cpu: "4"
memory: "8G"
applicationDatabase:
replicas: 3
storageSize: "64G"
storageClass: ${STG_CLASS_BLOCK}
resources:
requests:
cpu: "4"
memory: "8G"
limits:
cpu: "4"
memory: "8G"
For details on creating a MongoDB
Ops Manager instance, see Deploying MongoDB Ops Manager with a custom resource.Best practice: You can run the commands in
this task exactly as written if you set up environment variables. For instructions, see
Setting up installation environment variables.
Ensure that you source the environment variables
before you run the commands in this task.
Procedure
- Set two environment variables, BACKUP_MGDB_INSTANCE_NAME_1 and
BACKUP_MGDB_INSTANCE_NAME_2, to names you want to use for two MongoDB instances that
form a replica set.
export BACKUP_MGDB_INSTANCE_NAME_1=<name>
export BACKUP_MGDB_INSTANCE_NAME_2=<name>
- Run the following command to deploy a backup MongoDB instance that meets the
necessary configuration requirements:
cat <<EOF | oc apply -f -
apiVersion: mongodb.cpd.ibm.com/v1
kind: CPDMongoDB
metadata:
name: ${BACKUP_MGDB_INSTANCE_NAME_1}
namespace: ${PROJECT_CPD_INST_OPERANDS}
spec:
license:
accept: true
opsManager: ${OPS_MANAGER_INSTANCE_NAME}
replicas: 1
storageSize: "16G"
storageClass: ${STG_CLASS_BLOCK}
dedicated: false
resources:
requests:
memory: 1Gi
cpu: 1
limits:
memory: 1Gi
cpu: 1
EOF
Repeat the command by setting the
metadata.name
key to
BACKUP_MGDB_INSTANCE_NAME_2.
Important: Do not change the names of the backup instances
after they have been created.
Run the following command to confirm that the
MongoDB instances are in the
Running
phase:
% oc get mdb
The output should be similar to
the following example that shows two instances named
blog and
oplog:
NAME PHASE VERSION TYPE AGE
blog-mongodb Running 4.4.0-ent ReplicaSet 3d23h
mdb-mongodb Running 4.4.0-ent ReplicaSet 3d23h
oplog-mongodb Running 4.4.0-ent ReplicaSet 3d23h
- Configure Ops Manager to enable
backups.
- Run the following command to edit your custom
resource:
oc edit CPDMongoDBOpsManager ${OPS_MANAGER_INSTANCE_NAME}
- Add the following backup configuration to your custom resource under the
spec
key.backup:
enabled: true
headDB:
storageClass: ${STG_CLASS_BLOCK}
opLogStores:
- name: ${BACKUP_MGDB_INSTANCE_NAME_1}
mongodbResourceRef:
name: ${BACKUP_MGDB_INSTANCE_NAME_1}
blockStores:
- name: ${BACKUP_MGDB_INSTANCE_NAME_2}
mongodbResourceRef:
name: ${BACKUP_MGDB_INSTANCE_NAME_2}
- Confirm that your MongoDB
Ops Manager instance is running.
Run
the following command to check the status of your
Ops Manager
instance:
% oc get om
Check that the
STATE
(BACKUP)
returns
Running
. The output should be similar to the following
example:
NAME REPLICAS VERSION STATE (OPSMANAGER) STATE (APPDB) STATE (BACKUP) AGE WARNINGS
mongodb-om2-ops-manager 2 5.0.6 Running Running Running 3d23h
- Configure your instance to backup your data.
- Open the MongoDB
Ops Manager. See Administering with MongoDB Ops Manager for details.
- Navigate to the Organizations page from the MongoDB
Ops Manager.
- Click the MongoDB instance to backup.
- Click Continuous Backup in the navigation menu.
- Click >
Next.
- Choose your backup MongoDB instances as the Replica
Set or Cluster.
- Click Start Backup.
If you cannot see the snapshot, perform the below steps.
- Optional: Configure the Block store.
- In the MongoDB
Ops Manager home page, select
Admin.
- Click Backup.
- Click the Snapshot storage.
- Click Blockstores.
- Enter the "Write Concern" with
.
- Ensure that MongoDB authorization password is correct.
To check if security is enabled for your project, you can follow these steps:
- Connect to the database pod of the corresponding instance, the pod should be named as your
instance followed by
mongodb
.oc rsh mongodb-instance1-mongodb-0 -n <namespace>
- Review the configuration file using the command:
cat /data/automation-mongod.conf
If the parameter security.authorization
is not in the
/data/automation-mongod.conf
configuration file you do not need to add user and
password, otherwise you must refer to f.
Note:
If security is not enabled for the instance, no username or password is required when updating
the Blockstore configuration.
- Click Save.
- Optional: Configure the Oplog store
- In the MongoDB
Ops Manager home page, select
Admin.
- Click Backup.
- Click Oplog storage.
- Enter the "Write Concern" with
.
- Ensure that MongoDB authorization password is correct.
- Click Save.
The new configuration will be used for the next snapshot.