Mongodb – Mongo cluster – simple backup question

backupmongodb

I've got a mongo cluster with three nodes, running 2.6, but probably going to 3.2

What is the best method to back-up a database in a replica set of three mongodb servers?
Should I use mongodump --db [dbname] --out [path]?

And do I back-up from the primary node, or the slaves?
The database is about 30GB, so will the performance decrease during the backup of the other nodes?

I looked at the documentation here and here, but could not find my answer.

Best Answer

You could use:

  1. backup software (for automated snapshots of your data),
  2. mongodump/mongorestore,
  3. or a simple copy of the \data\db directory to your backup location.

For option 2, make sure to use mongodump with the --oplog option. If you need to restore, then use mongorestore with the --oplogReplay option.

With option 3, stop the secondary member, and copy the the data out. Or, if you do not desire to stop the secondary, use db.fsyncLock(), backup and then use db.fsyncUnlock().

Secondaries replica set members are ideal for reporting and backup use cases.

Reference: https://docs.mongodb.com/v3.2/core/backups/