-
-
Save sposmen/cf47fcaa327f6482e567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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