Last active
June 13, 2019 07:42
-
-
Save rijdz/48d6904e0c2e400e44a61c0c470f84ba to your computer and use it in GitHub Desktop.
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
#BACKUP | |
mongodump --db pp_helpdesk_prd -u admin_helpdesk -p ptPP1953da --out /var/backups/pp-helpdesk/`date +"%d-%m-%y"` | |
#RESTORE | |
sudo mongorestore --db newdb --drop /var/backups/mongobackups/13-06-19/pp_helpdesk_prd/ | |
#DELETE OLDER 30DAYS | |
find /var/backups/pp-helpdesk/ -mtime +30 -exec rm -rf {} \; |
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
db.createUser( | |
{ | |
user: "testUser", | |
pwd: "xyz123", | |
roles: [ { role: "readWrite", db: "test" } ] | |
} | |
) |
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
use reporting | |
db.grantRolesToUser( | |
"reportsUser", | |
[ | |
{ role: "read", db: "accounts" } | |
] | |
) |
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
#Connect | |
mongo admin -u admin -p <current_password> | |
MongoClient.connect('mongodb://admin:password@localhost:27017/db') | |
#Change Password | |
db.changeUserPassword(‘admin’,’<new_password>’) | |
#restart | |
db.adminCommand({ shutdown: 1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment