Created
November 16, 2012 19:46
-
-
Save kagemusha/4090276 to your computer and use it in GitHub Desktop.
mongodump mongorestore - base case
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
Ref: | |
http://docs.mongodb.org/manual/reference/mongodump/ | |
mongorestore --collection people --db accounts dump/accounts/ | |
Say you want to transfer your local mongo dbs to another machine. One way using dump and restore is: | |
1. run mongodump on old machine | |
- this will put all your mongo dbs in a directory called dump in the current dir | |
- for instance if you have one db called mydb, will have a dir dumb/mydb with your data | |
2. zip and transfer dump dir to new machine | |
3. after unzipping run mongorestore from the dir containing dump: | |
- e.g. to restore the db in step 1, do: | |
mongorestore --db db_to_restore dump/mydb | |
(where of course you sub your db name for mydb) | |
Note: | |
mongorestore will create a new db in named db doesn't exist. If it exists, it will add records which don't already exist. It will not update existing records. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment