0

I backup the server's MongoDB database with mongodump. Now I want to inspect the backup of the database.

The backup is in BSON and JSON formats:

$ ls <db-name>
contacts.bson  contacts.metadata.json ...

I want to run simple commands on the database, such as db.contacts.find({}) and possibly also complex ones, such as aggregation and projection.

I could use mongo-restore which would overwrite the production database. I could transfer it to another machine and restore it too. Both strike me as non-agile.

Does MongoDB allow quick inspection of a database backup?

miguelmorin
  • 5,025
  • 4
  • 29
  • 64

1 Answers1

1

If you want to query data in a database dump, load it into a running server and then query that server.

You can manually read a dump file, for example see here for the Ruby BSON API. This isn't something the vast majority of applications do though.

D. SM
  • 13,584
  • 3
  • 12
  • 21
  • Yes, both would work, and see [here](https://stackoverflow.com/questions/6770498/how-to-import-bson-file-format-on-mongodb) for the first with `mongorestore`. I ended up spinning a new virtual machine with a snapshot of the whole server, which was very fast. – miguelmorin Sep 15 '20 at 15:34