HOW TO: Copy remote db to local

Hello everybody,

I would like to copy the remote mongodb instance from the meteor infrastructure to my local environment.
I tried using the local mongo shell and the db.cloneDatabase() and db.copyDatabase() commands but couldn’t figure out which configuration parameters to use.

Can anyone provide an example configuration?


this is how I spend my database from production (mongolab) to localhost

to get the database

mongodump --host -d dbname -u username -p password

I send the db to localhost while the application is running

mongorestore --db meteor --drop -h localhost --port 3001 dbname

Thanks cottz, this was very helpful, but no it seems there’s a problem with authentication. It says:

assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

The user and password I specified are definitely correct as they allow me to connect to the database via meteor mongo.
Could it be that I also need to set the --authenticationDatabase <dbname> option? If so, what value would that be?

Does anyone have an idea?

I would suggest using a tool such as robomongo to test the connection to the production database, then once you have that correct use mongodump as suggested before.

I’m not sure if this is the issue but I was having trouble connecting using the mongo shell command, and then I found out my local version of mongo (2.x) was not compatible with Modulus’ mongo version (3.x)

Downloaded and installed newer mongo locally and all worked fine.

I connected to the db using meteor mongo and created another user “export” with the roles: ["backup"].
I can now connect to the database with mongodump but get the following error message:

assertion: 13106 nextSafe(): { $err: "not authorized for query on dbname.system.indexes", code: 16550 }

I tried different roles like “dbOwner” and event “root”, but I always get the same response.

This was actually a very useful resource on this topic: