0

I'd like to make a backup of a MongoDB replica set in a way that I can ensure the database consistency at the time when the backup starts. As the documentation says, --oplog flag to mongodump will copy also the oplog during the backup process. However, this ensures the integrity to point of time in the end of the backup process, that can be tens of minutes after the process started.

Some approached I've been thinking:

  • Shutting down one of the nodes at a given time and taking an offline backup directly from the datafiles.
  • Acquiring a global write lock to a node (is it even possible?) whichafter starting the backup process against this backup node.

Is there any other way to ensure that I'll get an exact (~5 seconds window) dump from a certain, defined time this way?

1 Answer 1

1

There are a few ways you can accomplish a "starting" point in time backup. Please note that the following is geared towards backing up a replica set. Backup for a sharded cluster has additional complexity.

1) Shut down mongod

Shut down a mongod process and either copy the files or perform a mongodump against your file set.

2) Lock/flush data

A db.fsyncLock() mongo shell call or execution of the associated fsyncLock command will prevent writes and allow you to copy your data/file set. This command will prevent writes and flush the data files.

3) Point-in-time filesystem snapshot

If you have a mechanism that allows a point-in-time snapshot of both your data and journal files, this can be used to obtain a point-in-time copy. On Linux a good way to accomplish this is via LVM, where data and journal files are in a single volume group.

4) MMS Backup

MongoDB Inc provides a backup service that will allow for point-in-time restoration. There are 2 options, either the cloud backup service or a hosted backup. Both are paid services, the first billed by usage and the second for MongoDB subscribers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .