Skip to content

Migration of MindSphere MongoDB to MongoDB Atlas

This documentation describes one of the procedures to migrate your MongoDB data hosted by MindSphere to an own account from MongoDB Atlas.


If you would like to use your application connected to a MongoDB Backing Service after October 31st 2020, then you need to take action.

Get Backup from MindSphere CloudFoundry MongoDB


The steps to get a backup which can be restored with mongorestore command differentiate between XS-sized and M-sized MindSphere CloudFoundry MongoDB instances.


Before creating, downloading a backup or MongoDB dump, make sure that no app is writing into your MongoDB instance.

XS-sized MindSphere CloudFoundry MongoDB Instances

The following steps are only valid for XS-sized service instances.

Download a Backup

  1. Open the Service Dashboard (see Backup and Restore Service Instances).
  2. Set an encryption key.
  3. Create a Backup.
  4. Download a Backup (see Download a Backup).

Decrypt Backup

To Decrypt backup, execute the following command:

cat <backupFile> | openssl enc -md md5 -aes256 -d -pass 'pass:<Encryption Key>' | gunzip -c > decrypted-backup
where, <Encryption Key> is the key that was set in the Service Dashboard, while downloading the backup.

M-sized MindSphere CloudFoundry MongoDB Instances

The following steps are necessary for M-sized service instances. However, they are also valid for XS-sized service instances.

Create ssh tunnel to MongoDB instances


For the creation of an ssh tunnel to your MongoDB instance, an app has to be bound to the MongoDB instance.

  1. Get host name and credentials of your MongoDB instance using CF CLI:
    cf env <app-name>
    where, <app-name> is the name of your app which is bound to your MongoDB instance.
  2. Note the default_database, master host name (incl. port), username and password of your MongoDB instance:
  3. Create tunnel to MongoDB instance by using the following command:
    cf ssh <app-name> -L <local-port>:<host-name-incl-port>`
    From the example screenshot above, the command is:
    cf ssh pymon -L 27017:mod16dfa2-mongod-initial-master-0.node.dc1.a9ssvc:27017
    where, pymon is the name of your app.

For more information refer Make a Service Instance Locally Available and Cloud Foundry SSH.

Create MongoDB Dump

After the tunnel to your MongoDB instance is open, you can create a dump of your database.

  1. Open another shell locally
  2. Install mongodump on local shell (see Mongodump).
  3. Create dump of your MongoDB instance with mongodump -h localhost:<local-port> -u "<username>" -p "<password>" --gzip --db=<default_database> --archive=backup.archive
    In the example screenshot, the command is:
    mongodump -h localhost:27017 -u "a9s-brk-usr-c47fc03fc7b51ba39c36cd7ef5ea0214cb44" -p "a9s503d87721c74d094457046192a2423bfe7ac" --gzip --db=mod16dfa2 --archive=backup.archive

Create MongoDB cluster and restore data on MongoDB Atlas

Create Cluster

  1. Open MongoDB Atlas.
  2. Sign In or Create Account.
  3. Create MongoDB Cluster .


For eu1, region create it on AWS in region Frankfurt
For eu2, region create it on Azure in region westeurope

create-mongodb-cluster 4. Create Database Access User create-mongodb-user. create-mongodb-user

Restore backup into Cluster

  1. Install mongorestore (see Mongorestore).
  2. On MongoDB Atlas, you can find you mongorestore command.
    Open your cluster on MongoDB Atlas and click on "Command Line Tools".
  3. Copy the restore command
    mongorestore --host MyCluster-shard-0/,, --ssl --username myUser --password <PASSWORD> --authenticationDatabase admin
  4. Replace <PASSWORD> by the <atlasPwd>, from <atlasUser>, that you have created.
  5. Add --gzip --archive=decrypted-backup to the end of the command. With this, the command is as below:
    mongorestore --host MyCluster-shard-0/,, --ssl --username myUser --password <atlasPwd> --authenticationDatabase admin --gzip --archive=backup.archive
  6. Execute the restore command.
  7. After restore has finished, you can see your database in MongoDB Atlas.
  8. Save the database name for future reference. In this example, it is mod34b0f4.

Change connection to MongoDB Atlas cluster in MindSphere CloudFoundry

  1. In MongoDB Atlas, navigate to your project and select "Clusters".
    Click on "CONNECT" button of your cluster you want to connect to. Select "Connect your application". connection-string
  2. Select your driver and version.
  3. Copy the connection string.
  4. Replace <password> with your <atlasPwd>, you have created.
  5. Replace the database name /test by the database that you have saved. For example mod34b0f4.
  6. With this changes, you will have a connection string like below:
    mongodb+srv://myUser:<atlasPwd> mod34b0f4?retryWrites=true&w=majority
  7. In CF CLI, create a User-Provided-Service.
    cf cups <> -p "uri"
  8. When requested for uri, insert your connection string.
  9. Unbind MindSphere CloudFoundry Backing Service from your app.
    cf us <myapp> <my-old-mongodb>
  10. Bind User-Provided-Service to your app.
    cf bs <myapp> <>
  11. Restage your app.
    cf restage <myapp>


  • Remember to change the service instance name to the User-Provided-Service in your manifest.yml
  • MongoDB TLS/SSL is standard
  • Latency time may be higher than before
    Tipp: Create DB in AWS Frankfurt to minimize the latency time
  • Your application may need more outbound traffic
  • Keep in mind that your database endpoint is now accessible over internet. Please consider the security recommendations below and implement all additional security measures recommended by your organization.

Security Recommendations

  • Whitelist MongoDB Atlas cluster Access for MindSphere CloudFoundry IP addresses only.
    You can find the CloudFoundry IP addresses here.

Any questions left?

Ask the community

Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.