Skip to content

Instantly share code, notes, and snippets.

@rijdz
Last active June 13, 2019 07:42
Show Gist options
  • Save rijdz/48d6904e0c2e400e44a61c0c470f84ba to your computer and use it in GitHub Desktop.
Save rijdz/48d6904e0c2e400e44a61c0c470f84ba to your computer and use it in GitHub Desktop.
#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 {} \;
db.createUser(
{
user: "testUser",
pwd: "xyz123",
roles: [ { role: "readWrite", db: "test" } ]
}
)
use reporting
db.grantRolesToUser(
"reportsUser",
[
{ role: "read", db: "accounts" }
]
)
#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