Last active
May 25, 2016 21:34
-
-
Save elhoyos/6e6b0d18810e2edc0b05 to your computer and use it in GitHub Desktop.
mongo: Copy a collection
This file contains 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 |
This file contains 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 --version | |
mongodump version: r3.2.6 | |
git version: 6dab8f99eaafb764443531dc528d4b4b76eb57f2 | |
$ mongodump -h {HOST} -d {DATABASE} -u {USER} -p {PASSWORD} -c {COLLECTION} -o - | mongorestore -h {HOST} -d {DATABASE} -u {USER} -p {PASSWORD} -c {COLLECTION} --dir - | |
# To s3 | |
$ mongodump -h {HOST} -d {DATABASE} -u {USER} -p {PASSWORD} -c {COLLECTION} -o - | gzip -c | aws s3 cp - s3://{BUCKET}/{FILENAME}.gz |
This file contains 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
$ mongoexport -h host -u user -p password -d db -c collection | mongoimport -h target_host -d db -c collection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment