Scheduling MongoDB Database Backups

Configure backups

Click the Config button next to your database.

mongodb backup

Navigate to the scripts folder and open the file. In this file find the following line and state your values:

<MONGO_USERNAME> and <MONGO_PASSWORD> are your database username and password which you received via email after adding MongoDB.

<DAYS_TO_STORE> is the period of storing the backup files (the default value is 3)

Save the changes.


Open the cron folder and choose the mongod file.

Uncomment the following line:

@daily /bin/bash /var/lib/jelastic/bin/

Save the changes.

As a result your database will be backed up once per day (at night) according to the default configurations.


If you’d like to backup your database with the other frequency, you need to configure how often the script should run. To do this add the cron settings instead of the default value (@daily).

For example, if you prefer to backup your database every ten minutes this string will be as follows:

*/10 * * * * /bin/bash /var/lib/jelastic/bin/

Save the changes.


You can also configure the backup of specific databases.

To do this navigate to the scripts folder, open the file and uncomment the following string as it is shown below:

# DATABASES_LIST=(“db1” “db2”); ###

backup few databases

Paste the names of databases you want to backup instead of “db*” values (separated with space) and Save the changes made.

Checking backups

Wait for the time of the backup you’ve scheduled while setting.

Navigate to the Configuration tab and open the backup folder (/var/lib/jelastic/backup). There .tgz files with all executed backups are stored.

deployment manager

Download Backup

Install FTP for your database server. Find detailed instructions here.


Connect to MongoDB using an FTP client (e.g. FileZilla) and download your backup .tgz archive.

ftp client

Restore database from a backup

Unzip the downloaded backup package.

Open the folder with the name of the database or the collection you’d like to restore and find the collection .bson file.

Convert bson file into the json format running the following command:

bsondump my.bson > my.json

Note: You need to install MongoDB on your local machine. Place the bson file to the mongodb…/bin folder and run the above mentioned command under this directory. The generated json file will be stored in the same folder.

Access the RockMongo admin panel with the credentials you’ve got after adding MongoDB.

Navigate to the existing database to restore the data in it or create a new one.

Open the Import tab and download your json file stating the collection where you want to place it.


As a result you can see that all your data is successfully restored.

in Jelastic



Related Articles