Want to do an incremental backup for mongodb. Journaling? Oplog?

ぐ巨炮叔叔 提交于 2020-01-20 19:51:27

问题


I want to daily backups for a single mongodb database, probably with mongodump. To not lose any data, I would like this to be incremental so if something goes wrong in the middle of the day, I need to be able to replay changes for that day up til the point of failure after doing a mongorestore.

Am I understanding correctly that I need to use an oplog for this? Or is journaling the answer? I tried doing the following:

  1. Turning my mongo database into a replica set of just one, so that it creates an oplog. (This feels pretty hacky)
  2. Restarting mongod with the --oplog option
  3. Performing changes that should be recorded in the oplog

However nothing ever gets stored in the oplog. What is the best way to do such incremental backups? I'm basically looking for a similar approach to replaying the mysql binlog.

Thanks


回答1:


MongoDB doesn't provide an incremental backup option out of the box, but it's possible to do a file snapshot and replay the oplog. Did you set up your server as a replica set following the steps outlined in the documentation? http://www.mongodb.org/display/DOCS/Replica+Sets+-+Basics

Could you also tell us the purpose of these backups? Have you considered adding a second node to your replica set for data durability?

If you've walked through the steps to set up the server as a member of a replica set, can you run rs.status() in the shell?

One other note (just to clarify)- journaling is not meant to be a backup strategy; journaling merely ensures that the database can return to a consistent state in the event of failover. Running with journaling enabled is highly recommended.

Here is the MongoDB documentation for backups: http://www.mongodb.org/display/DOCS/Backups




回答2:


The best way to do the backups is to configure Ops Manager as part of your MongoDB infrastructure, but it does so much more than just backups...



来源:https://stackoverflow.com/questions/11974071/want-to-do-an-incremental-backup-for-mongodb-journaling-oplog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!