简体   繁体   中英

How to inspect a MongoDB backup database?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM