TLDR; What's the easiest way to automate a mongodb backup of a 20-gig DB?

We run mongo on the same KVM (VPS) as the web app; the server runs Debian.

We/I don't need/want to backup the entire fs on a daily basis, but definitely the Mongodb database.

I don't really want to put Mongo in a separate volume, it complicates things and increases likelihood of downtime, especially when I need to expand the volume in question. However, using the LVM to create snapshots seems like the easiest (actually, the only) way forward.

I've been told that when oplog is in use hot snapshots won't be corrupt.

I found this guide demonstrating how to set up this backup method, but it's almost 10-years out of date. Is there an easier way?

I have read everything I could find, several times, on the man-pages.

Thanks for reading :)


Yes, hot snapshot is easy and fast way to do backup... But of course there is also mongodump. Here is my crontab entry. Every hour, overriding current date backup.

DATEVAR=date +%d
31 * * * * /usr/bin/mongodump --host localhost -o /dbdata/dump$($DATEVAR) --gzip --oplog >> /dev/null 2>&1
  • Thanks :) . The docs say "When connected to a MongoDB instance, mongodump can adversely affect mongod performance. If your data is larger than system memory, the queries will push the working set out of memory, causing page faults." So I plan on avoiding mongodump, altogether. – harry young Apr 20 at 21:31
  • Yes, snapshots are easiest and fastest way to do backup. And yes, it's better if that data is on it's own partition. You can easily check if mongodump will affect your clients. But I guess that nobody would even notice that moment when you dump data out. With 20GB data, it's quite fast. – JJussi Apr 21 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.