Import/export of Mongo DB to Mongolab

So today I decided it’s time for the app to be live on the internets!

First off, I migrated the app to heroku (pretty straightforward process, instructions can be found here: https://devcenter.heroku.com/articles/nodejs and I wrote about migration to Heroku/Mongolab my post)

Then, of course, needed to migrate the existing local mongo database to Mongolab.

Step 1: export your local mongo database using mongodump:

In terminal, find your mongo directory and run

./mongodump or bin/mongodump

This will create a directory “dump” with all existing databases and collections

Note: if you only need to export certain databases or collections, read up the instructions on the mongo site

Step 2: import your dumped db files to Mongolab:

bin/mongorestore -h .mongolab.com: -d  -u  -p  dump/

The values for db name, port, app id can be easily found through Mongolab admin console:

As you see, once imported, your collections will be listed in the admin console.

2 thoughts on “Import/export of Mongo DB to Mongolab

  1. Ian Dee

    Hey Tanya, I found this super helpful while trying to sync my local database with an mLab project. Much clearer and way more concise than reading through the official mongo docs. Nice work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s