Skip to main content
Version: 1.3

MongoDB Backup

Prerequisites

  • MongoDB database asset
  • MongoDB credentials
  • Storage bucket asset
  • Storage bucket asset credentials

Procedure from web console

  • Navigate to the policy's page: Operations > Policies (or go directly to /home/operations/policies)
  • Click on Create Policy button
  • Select MongoDB backup
  • Fill out the MongoDB backup policy form with the following information:
    • Policy name: Enter a descriptive name for your backup policy
    • The MongoDB asset to backup: Select the MongoDB instance from the dropdown
    • The credential name to access MongoDB: Select the credential bound to the MongoDB asset from the dropdown
    • The database name to backup: Specify the name of the database you want to backup
    • The opts for MongoDB backup: Configure additional backup options (optional)
    • The Bucket asset where backups will be saved: Choose the storage bucket from the dropdown
    • The credential name to access Bucket: Select the credential bound to the Bucket from the dropdown
    • The path inside the bucket where backup is saved: Define the storage path within the bucket
    • The backup schedule in Cron format: Set the backup frequency using cron syntax (e.g., 0 2 * * * for daily at 2 AM)
    • Enable GZIP compression: Check this option to compress backups
    • Click Next to continue with the policy configuration
  • Select the target cluster where you want to deploy the policy (optional - if not specified, the policy will be deployed to the default cluster)
  • Review the policy configuration summary
  • Click Create Policy to deploy the MongoDB backup policy

Procedure from CLI

Create a YAML file with the policy configuration:

apiVersion: operations.resiliency.io/v1alpha1
kind: Policy
metadata:
name: <policy-name>
namespace: resiliency-system
spec:
templateName: mongodb-backup
params:
- name: mongodb-asset
value: <mongodb-asset-id>
- name: mongodb-database
value: <database-name>
- name: bucket-asset
value: <bucket-asset-id>
- name: mongodb-opts
value: "<backup-options>"
- name: bucket-path
value: "<path-in-bucket>"
- name: schedule
value: "<cron-schedule>"
- name: use-gzip
value: <true|false>
- name: bucket-credential
value: <bucket-credential-name>
- name: mongodb-credential
value: <mongodb-credential-name>
placement:
clusterName: <target-cluster-id>
createNamespace: true
credentialName: <cluster-credential-name>
suspended: false

Apply the policy to the cluster:

kubectl apply -f mongodb-backup-policy.yaml

Policy Specification

FieldTypeRequiredDescriptionExample
metadata.namestringYesUnique name for the policymongodb-backup-daily
metadata.namespacestringYesNamespace where policy is createdresiliency-system
spec.templateNamestringYesTemplate to use for the policymongodb-backup
spec.suspendedbooleanNoWhether the policy is suspendedfalse
spec.paramsarrayYesArray of parameters for the templateSee parameters table below
spec.placement.clusterNamestringNoTarget cluster ID5b2613a542a883618f0fe1da26396a721d063219
spec.placement.credentialNamestringNoCluster credential namecluster-admin
spec.placement.createNamespacebooleanNoCreate namespace if it doesn't existtrue

Parameters (MongoDB Backup)

ParameterTypeRequiredDescriptionExample
mongodb-assetstringYesID of the MongoDB asset44bd1dd01554be8285626843082c5eaca28f6779
mongodb-databasestringYesDatabase name to backupproduction
mongodb-credentialstringYesCredential name for MongoDB accessmongodb-root
bucket-assetstringYesID of the bucket asset01409a2b09f336c6533729d4c04866803ec8bf67
bucket-credentialstringYesCredential name for bucket accessaws-s3-backup
bucket-pathstringYesPath within bucket for backups/backups/mongodb
schedulestring (cron)YesBackup schedule in cron format0 2 * * *
mongodb-optsstringNoAdditional mongodump options--gzip --oplog
use-gzipbooleanNoEnable GZIP compressiontrue