Last active
August 12, 2016 10:36
-
-
Save sanjay1688/fd8d20212b3dba209ac3 to your computer and use it in GitHub Desktop.
Monogdb useful commonds
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
Service | |
sudo status mongodb //tell status of mongodb start or stop | |
sudo service mongodb restart | stop | start | |
Config | |
#bind_ip = 127.0.0.1 //comment it which so anyone can connect using mongo client | |
//copy db from one host to another host or in host | |
db.copyDatabase('from_db', 'to_db', 'from_hostname', 'username', 'password'); | |
//find region_tags not empty | |
db.finders.find({"location.region_tags":{$not: {$size: 0}}},{_id:1,slug:1,title:1,slug:1,'location.region':1,'location.region_tags':1}).limit(1000) | |
###################### MONGO BACKUP ###################### | |
For a full DB restore: | |
mongorestore --drop -d db dump/db | |
mongodump -d pets -o petsbackup | |
mongodump -h domain:27017 -d talentx talentxbk/talent | |
mongorestore -h domain:27017 -d talentx talentxbk/talentx | |
mongorestore -h domain:27017 --drop -d talentx talentxbk/talentx | |
mongorestore -h domain:27017 -c reviews_copy -d db dump/db/reviews_copy.bson | |
db.copyDatabase('db1', 'db2') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment