Skip to content

Instantly share code, notes, and snippets.

@etoxin
Last active June 22, 2017 06:00
Show Gist options
  • Save etoxin/3011ff6f63a345d5548aa56337f2d558 to your computer and use it in GitHub Desktop.
Save etoxin/3011ff6f63a345d5548aa56337f2d558 to your computer and use it in GitHub Desktop.
Export a Mongo DB database

Export a mongo Database

first step is to list all databases. Get into the mongo terminal with mongo and run the follwing command to show all the DBs

show dbs

Show collections

use databaseName
show collectons

Then find the name of the DB.

Export a single collection as json.

mongoexport --db databaseName --collection collectionName --out output.json

Dump DB

to export the entire DB run

mongodump -d mydatabasename -o ./folderToExport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment