Want to do an incremental backup for mongodb. Journaling? Oplog?
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:
- Turning my mongo database into a replica set of just one, so that it creates an oplog. (This feels pretty hacky)
- Restarting mongod with the --oplog option
- 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.
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
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...