Upload
prem-regmi
View
1.775
Download
0
Tags:
Embed Size (px)
Citation preview
Backup and Restore Database in MongoDB
By: Prem Regmi
RESTORING THEM
What’s the most important thing about making backups?
Backup Options
• Mongodump• Copy files• Snapshot disk
mongodump
• Dumps collections to *.bson files• Mirrors your structure• Can be run in live or offline mode-
mongodump
mongodump
• Type mongodump in your terminal• mongodump --db hero(hero is the database
name)• Database save inside dump folder
mongodump
mongorestore
• mongorestore• Restore all database inside dump
Repair• Repair all databases on the server:
• $ mongod –repair
• Repair Database command to repair a single
• database:
> use project_development
> db.runCommand({repairDatabase: 1})
• which operate on a single collection :
rebuild indexes>use tuotorial_development> db.employee_qualifications.reIndex()
compact the collection
> db.runCommand({ compact: "employee_qualifications" }
Recover MongoDB
• Unexpected Shutdown• Error: couldn't connect to server 127.0.0.1
shell/mongo.js:84
Solution
• Remove the mongod.lock file• Run the --repair process