backup, restore, and disaster recovery
DESCRIPTION
TRANSCRIPT
Software Engineer, 10gen
Craig Wilson
#MongoDBDays
Backup, Restore, and Disaster Recovery
You Gotta Back It UpTo Get It BackLeo Laporte
Even More ImportantRestoring It
Slightly Less, But Still Very ImportantPractice
Backups with MongoDB
• Not difficult– Multiple options– Choose the one that fits your needs
• Can be automated
• Practice
Choices
Choices
• Selectivity
• Live/Offline
• Efficiency
• Backup Size
• Environment Constraints
mongodump
• Dumps collections to *.bson files– Use bsondump to view these files
• Mirrors your structure
• Can be run in live or offline mode
• --dbpath for direct file access
• --oplog to dump oplog last PIT
• --query/filter selective dump
mongorestore
• Selected dbs, collections
• --oplogReplay
File System - fsync +lock• No more writes
• Copy the data files
• Remember to unlock
File System - Snapshot
• Snapshot– Journaling needs to be on– Journal needs to be on the same volume
File System
• Entire database
• Backup files will be large
• Fastest way to create a backup
• Fastest way to restore a backup
Disaster Recovery
Replica SetsDisaster Avoidance
Disaster Avoidance
• Redundancy
• Multiple Datacenters
• Multiple Regions
> rs.conf() { "_id" : "replSetName", "version" : 3, "members" : [ { "_id" : 0, "host" : "myhost1.dnsname.com:27017“, “tags” : { “dc” : “east” } }, { "_id" : 1, "host" : "myhost2.dnsname.com:27017“, “tags” : { “dc” : “east” } }, { "_id" : 2, "host" : "myhost3.dnsname.com:27017“, “tags” : { “dc” : “west” } }] }
Disaster Avoidance
Disaster Recovery Logistics• Recovery (restore) time
• Replacement– Machine– Component (disk, memory, etc)– Cluster
• Configuration (reconfiguration)
Sharded Systems
Sharded Systems
• No true point in time
1. Stop balancing – sh.stopBalancer()
2. Stop one config server (data R/O)
3. Backup Data (shards, config)
4. Restart config server
5. Resume Balancer
What have we discussed?
What have we discussed?• You have Options
• It’s not difficult
• Practice!
Software Engineer, 10gen
Craig Wilson
#MongoDBDays
Thank You