Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to create backup in MongoDB

James MA

Use the mongodump command for creating binary backups for your MongoDB instances.

Suppose you can access your MongoDB instance using this connection string:


And, you have the mongodump utility tool installed and accessible from your Terminal. (If it’s not, visit the MongoDB Database Tools Installation Guide before continuing with the steps below.)

Lastly, determine your backup destination folder. An example is, /backups/20210404/.

The command to kick off the final backup process would look like:

mongodump --uri="mongodb://" --out /backups/20210404/ -v

Here, I added the -v flag (short for --verbose mode) to display more reporting on the backup progress.

It should take some time to run. Once done, the dumped database will appear as bson files. You can then copy these files to another secured location or import them into another MongoDB instance.

You can use additional options, such as --gzip to compress the output and --archive to output the database dump to an archive file.

See the mongodump page for a full list of available backup options.



View all Courses

Keep Exploring