Skip to content

Instantly share code, notes, and snippets.

@sposmen
Forked from elhoyos/binary
Last active August 29, 2015 14:04
Show Gist options
  • Save sposmen/cf47fcaa327f6482e567 to your computer and use it in GitHub Desktop.
Save sposmen/cf47fcaa327f6482e567 to your computer and use it in GitHub Desktop.
// Connect to origin db
use some_database; // This will be named db
// Connecto to destiny db2
db2 = db.getSiblingDB('some_other_db');
// Only if needed clean destiny collection
db2.some_or_other_collection.remove({});
// Search all origin collection and copy each to destiny collection
db.some_collection.find()
.forEach( function( data ) {
db2.some_or_other_collection.insert(data);
}
);
$ mongodump -d some_database -c some_collection
$ mongorestore -d some_other_db -c some_or_other_collection dump/some_collection.bson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment