Afshin Mehrabani

Scheduled backup for MongoDB

May 29, 2015

MongoDB is one of NoSQL pioneers and it has a great community. Nowadays, most of startups prefer to use MongoDB as the main database because of its simplicity. Configuring scheduled backup for a database is really important to keep the last updated data somewhere and restore it in case of database crash.

In this post I want to introduce a simple open-source tool that I’ve recently published to setup a minimal scheduled backup for MongoDB.


I built this tool using Node.js so first of all you need to install I will publish a binary version for all platforms soon.

You need no more dependencies but official Node.js module. In the next step we will install them using npm.


I named this tool mongodb-backup and you can clone the repository from Github:

Then go to the folder of project and run following command:

npm install

This command installs all required dependencies including AWS sdk.


This tool has a simple config.js file that defines all dependencies to run the mongodump command and upload it to the Amazon S3 storages. Here you can find a list of all dependencies:

Go go go

Final step is to run the script. You can run the cronjob using following command:

node index.js start

And if you want to run the script as a deamon, install forever using npm install forever and then run this command:

forever start index.js start


This version of mongodb-backup works with Amazon S3 but I will publish another version soon that accepts FTP and SFTP to transfer backup files.

← Back to all articles