Shameless Mongo Restore

Found originally on Slashdot.com but this solution sounds way better then writing custom code. Consider the Team members in all you do ….

___________________________________________

You can do this with the command line tools mongodump and mongorestore.

Use mongodump –db [dbname] on the source computer to export all collections of the database into files

which are stored in the directory /dump/[collection].bson. Copy the files to the target computer

and then use mongorestore –db [dbname] [collection].bson to import the generated files into the consolidated database.

The contents will be appended to the existing collections as if you would use the insert command.

When you want to do it like a senior sysadmin: both command line tools have command line options to perform said operations on a remote system

and you can pipe the output of mongodump right into mongorestore, so when you want to show off you could do it with one console

command from a remote system. But when this is a one time thing and command line trickery is not your passion, rather stick to files.

 

or automate completely ..hmmmm !!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s