How to create backup in MongoDB
Use the
mongodumpcommand for creating binary backups for your MongoDB instances.
Suppose you can access your MongoDB instance using this connection string:
mongodb://mongodb0.example.com:27017
And, you have the mongodump utility tool installed and accessible from your Terminal. (If it’s not, visit the
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://mongodb0.example.com:27017" --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
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
for a full list of available backup mongodump page https://www.mongodb.com/docs/database-tools/mongodump/ . options https://www.mongodb.com/docs/database-tools/mongodump/