Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB: mongodump/restore vs. backup up files directly

Tags:

mongodb

I'm wondering about experiences people have had with MongoDB backups. Assuming a filesystem snapshot is not an option, what have your experiences been with mongodump/restore versus doing a write lock and backing up the files? Have you run into any bugs with one method that caused you to switch?

From the reading I've done so far, it seems like mongodump/restore has the advantage of being able to run it while the server is live, but I'm not sure how well it will scale.

like image 566
kclair Avatar asked Mar 16 '12 16:03

kclair


1 Answers

Locking and copying files is only an option when you don't have heavy write load.

mongodump can be run against live server. It will create some additional load, so don't do it on peak hours. Also, it is advised to do it on a secondary node (if you don't use replica sets, you should).

There are some complications when you have a DB so large that no single machine can hold it. See this document.

Also, if you have replica set, you take down one of secondaries and copy its files directly. See http://www.mongodb.org/display/DOCS/Backups:

A simple approach is just to stop the database, back up the data files, and resume. This is safe but of course requires downtime. This can be done on a secondary without requiring downtime, but you must ensure your oplog is large enough to cover the time the secondary is unavailable so that it can catch up again when you restart it.

like image 153
Sergio Tulentsev Avatar answered Sep 22 '22 16:09

Sergio Tulentsev