2. Why backup?
Availability vs. recovery
Cost is impacted by these decisions…
How much data can you afford to lose?
How long can you afford to be off-line?
Ref: “MongoDB Backups & Disaster Recovery”
http://www.mongodb.com/presentations/webinar-backups-and-disaster-
recovery
2.
4. Two kinds of backup
One-time snapshot
Capture a consistent snapshot at a specific
point in time
Not easy in a distributed zero-downtime
production system.
Incremental backup
Capture differences since last one-time
snapshot
Oplog is N/A in MongoDB config servers (to be
discussed later)
4.
9. One-time snapshot steps
1. Stop balancer (mongos + config)
2. Take snapshot of config data
3. For each shard, take snapshot of one
secondary
4. Re-start the balancer
5. Copy snapshots in steps 2 & 3
Ref: “Backup a Sharded Cluster with Filesystem Snapshots”
http://bit.ly/1hqO1kj
9.
12. Stop balancer… Why?
“If MongoDB migrates a chunk during a backup, you can
end with an inconsistent snapshot of your sharded
cluster. Never run a backup while the balancer is
active.”
Ref: “Disable Balancing During Backups”
http://bit.ly/1rnRMfV
12.
13. #1: Stop balancer
var sleep_time_in_ms = 10000;
sh.setBalancerState(false);
while (sh.getBalancerState()
|| sh.isBalancerRunning()) {
sleep(sleep_time_in_ms);
}
// now the balancer is stopped…
Ref: “Disable Balancing During Backups”
http://bit.ly/1rnRMfV13.
16. Snapshot the “dbpath”
Snapshoting step, almost the same:
#2: Config server
#3: Secondary
… but just one difference:
“Never use db.fsyncLock() on config
databases.”
Ref: “Backup a Sharded Cluster with Filesystem Snapshots”
http://bit.ly/1hqO1kj
16.
29. Oplog in real-life
Replication lag
Inspect it in real production environment!
Oplog is N/A in MongoDB config servers
… Still need to deal with the balancer
… Still need to use snapshot techniques
29.