MongoDB Backup And Restore

The simplest way to backup and restore MongoDB data is to use bson dumps. This is achieved by using the mongodump and mongorestore utilities and works best for small databases.


Create a directory first where you wanted to store all your MongoDB backups then run the following command (assuming you have authentication set).

mongodump --host --authenticationDatabase admin --forceTableScan -u username -p password-here

The command above should create a dump directory where all your Mongo database files are stored. Check the documentation for the mongodump parameters.


To restore, use the mongorestore utility. Run the following command (assuming you have authentication set).

mongorestore --host --db dbname --username username --password password-here --authenticationDatabase admin dump/dbname

That’s it! For more advanced backup/restore strategy, you can explore incremental backups, volume based backups or even third party services that provides MongoDB backups.

2 thoughts on “MongoDB Backup And Restore”

Leave a reply

Your email address will not be published. Required fields are marked *