A summary of available MongoDB backup options. We manage backup for hundreds of MongoDB servers at scalegrid.io and we have learnt a few things along the way.
2. Multiple options
• All backups are full database backups
• MongoDB currently does not officially support
diff backups
• Three options
– MongoDump & MongoRestore
– LVM snapshots
– Cloud snapshots
3. Mongodump & MongoRestore
• Pros
– Fairly simple to use and script
• Cons
– For a larger database it can take hours to backup.
– Need a additional disk of the same to store dump
– Database is online during backup – so not a point
in time snapshot (big problem)
4. LVM snapshots
• Four easy steps
– Deploy MongoDB data on a LVM volume
– Fsync and Lock mongodb to prevent writes (during snap)
– Snapshot volume using LVM commands
– Copy data from snapshot to final destination (NFS share, S2,
Swift) etc
• Pros
– Point in time snapshot of the database
• Cons
– Needs preplanning. Mongodb needs to be deployed on LVM
– More complexity. Need to understand LVM
– Copy of the data takes significant cpu cycles and time
5. Cloud snapshots
• Most cloud volumes today have volume
snapshotting functionality. E.g. EC2 EBS snapshot,
CloudStack volume snapshot etc
• Technique is identical to LVM snapshots but no
copy of data is involved
• Pro
– Simple to use and automate
– Point in time copy of data
• Cons
– Opaque format. Don’t have access to data offline
unless you create a new volume
6. MongoDirector.com backups
• Our preferred option is Cloud Snapshots
• If Cloud snapshots are not available we use
LVM snapshots
• We don’t use mongodump and monorestore
• More details in these blog posts
– Mongodb backup and restore
– Mongodb auto backup