Backup and Restore Databasein MongoDBBy: Prem Regmi
What’s the most importantthing about making backups?RESTORING THEM
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 fol...
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:   >...
Recover MongoDB• Unexpected Shutdown• Error: couldnt connect to server 127.0.0.1  shell/mongo.js:84
Solution• Remove the mongod.lock file• Run the --repair process
Backup, restore and repair database in mongo db linux file
Backup, restore and repair database in mongo db linux file
Upcoming SlideShare
Loading in …5
×

Backup, restore and repair database in mongo db linux file

3,707 views

Published on

Published in: Technology
1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total views
3,707
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
30
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide

Backup, restore and repair database in mongo db linux file

  1. 1. Backup and Restore Databasein MongoDBBy: Prem Regmi
  2. 2. What’s the most importantthing about making backups?RESTORING THEM
  3. 3. Backup Options• Mongodump• Copy files• Snapshot disk
  4. 4. mongodump• Dumps collections to *.bson files• Mirrors your structure• Can be run in live or offline mode-
  5. 5. mongodump
  6. 6. mongodump• Type mongodump in your terminal• mongodump --db hero(hero is the database name)• Database save inside dump folder
  7. 7. mongodump
  8. 8. mongorestore• mongorestore• Restore all database inside dump
  9. 9. 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" }
  10. 10. Recover MongoDB• Unexpected Shutdown• Error: couldnt connect to server 127.0.0.1 shell/mongo.js:84
  11. 11. Solution• Remove the mongod.lock file• Run the --repair process

×