Skip to content

Instantly share code, notes, and snippets.

@brendannee
Created January 7, 2014 00:05
Show Gist options
  • Save brendannee/8292378 to your computer and use it in GitHub Desktop.
Save brendannee/8292378 to your computer and use it in GitHub Desktop.
Dump a mongo collection, or part of a collection from a remote server and import locally
mongodump -u <USERNAME> -p<PASSWORD> --host <HOSTNAME>:<PORT> --collection <COLLECTION_NAME> -db <REMOTE_DATABASE_NAME> -o ~/Downloads
mongorestore --collection <COLLECTION_NAME> --drop -db <LOCAL_DATABASE_NAME> ~/Downloads/<PATH TO BSON FILE>
# http://stackoverflow.com/questions/7828817/is-it-possible-to-mongodump-the-last-x-records-from-a-collection/18679197#18679197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment