Want to know how the backup of mongo database can be taken. Read below…
Four tools are described here.
mongoexport can be used to take the backup of a mongo database. It takes the backup to a CSV, TSV or JSON files. The syntax is as follows.
mongoimport can be used to import a backup to a database. You can import from the backup file as follows.
For those who need a complete backup of the database, you can use mongodump command to do so. Unlike mongoexport, the backup will be done into a folder and not file.
Once completed, the backup will be present in /backuptest/db_test/
To restore an entire database, you can use the mongorestore command. Let’s restore the backup that we took in the previous step.
Try it and see, it works 🙂