Skip to content

Latest commit

 

History

History
21 lines (12 loc) · 898 Bytes

mongo-restore-collection.md

File metadata and controls

21 lines (12 loc) · 898 Bytes

Restore single collection to MongoDB

mongorestore --db={{DB_NAME}} --collection={{COLLECTINO_NAME}} {{COLLECTION_BSON_FILE}}

  • DB_NAME: DB to get backup from
  • COLLECTION_NAME: Collection which needs to be dumped in destination directory
  • COLLECTION_BSON_FILE: Location of the collections bson file which was generated by mongodump command

Example:

mongorestore --db=ak-cli --collection=cli_commands /arshad/ak-cli/db/dump/cli_commands.bson

To drop the collection before importing, add --drop flag at the end of the command. Something like the below command.

mongorestore --db=ak-cli --collection=cli_commands /arshad/ak-cli/db/dump/cli_commands.bson --drop

  • --drop: Drop flag, drops the collection before proceeding with import.

Related Commands