Top Banner
Senior Solution Architect, 10gen Chad Tindel #MongoDBDays Backup, Restore, and Disaster Recovery
25

Backup, Restore, and Disaster Recovery

Jan 15, 2015

Download

Documents

MongoDB

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Backup, Restore, and Disaster Recovery

Senior Solution Architect, 10gen

Chad Tindel

#MongoDBDays

Backup, Restore, and Disaster Recovery

Page 2: Backup, Restore, and Disaster Recovery

Agenda

• Backup

• Recover

• Disaster recovery

• Know your options

Page 3: Backup, Restore, and Disaster Recovery

Backup

Page 4: Backup, Restore, and Disaster Recovery

What’s the most important thing about making backups?Restoring them

Page 5: Backup, Restore, and Disaster Recovery

If you don't ensure that your backups can be restored, there's no point in doing backups

Page 6: Backup, Restore, and Disaster Recovery

Backup Options

• Mongodump

• Copy files

• Snapshot disk

Page 7: Backup, Restore, and Disaster Recovery

mongodump

• Dumps collections to *.bson 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

Page 8: Backup, Restore, and Disaster Recovery

$ mongodump --helpExport MongoDB data to BSON files.

options: --help produce help message -v [ --verbose ] be more verbose (include multiple times for more

verbosity e.g. -vvvvv) --version print the program's version and exit -h [ --host ] arg mongo host to connect to ( /s1,s2 for --port arg server port. Can also use --host hostname -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files in path, instead of connecting to a mongod needs to lock the data directory, so can if a mongod is currently accessing the s -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) -o [ --out ] arg (=dump)output directory or "-" for stdout -q [ --query ] arg json query --oplog Use oplog for point-in-time snapshotting

mongodump

Page 9: Backup, Restore, and Disaster Recovery

Restore

Page 10: Backup, Restore, and Disaster Recovery

mongorestore

• mongorestore

• --oplogReplay replay oplog last PIT

Page 11: Backup, Restore, and Disaster Recovery

File System

• Must use journaling

• File system snapshot

• Copy /data/db files

• Seriously, always use journaling

Page 12: Backup, Restore, and Disaster Recovery

File System

• fsyncLock flush and stop accepting writes

• Don't forget to fsyncUnlock

Page 13: Backup, Restore, and Disaster Recovery

File System

• Entire database

• Backup files will be large

• Fastest way to create a backup

• Fastest way to restore a backup

Page 14: Backup, Restore, and Disaster Recovery

Restore Options

• Entire database

• Replay Oplog

• Selected dbs, collections

Page 15: Backup, Restore, and Disaster Recovery

Disaster Recovery

Page 16: Backup, Restore, and Disaster Recovery

Replica SetsDisaster Avoidance

Page 17: Backup, Restore, and Disaster Recovery

> rs.conf() {"_id" : "replSetName","version" : 3,"members" : [ { "_id" : 0, "host" : "myhost1.dnsname.com:27017" }, { "_id" : 1, "host" : "myhost2.dnsname.com:27017" }, { "_id" : 2, "host" : "myhost3.dnsname.com:27017" }] }

Disaster Recovery

Page 18: Backup, Restore, and Disaster Recovery

Avoid single point of failure

NEW IMAGE?

Page 19: Backup, Restore, and Disaster Recovery

Disaster Recovery

• Redundancy

• Multiple Datacenters

• Multiple Regions

Page 20: Backup, Restore, and Disaster Recovery

Disaster Recovery

• Recovery (restore) time

• Replacement– Machine– Component (disk, memory, etc)– Cluster

• Configuration (reconfiguration)

Page 21: Backup, Restore, and Disaster Recovery

Examples

Page 22: Backup, Restore, and Disaster Recovery

Backup Example: Sharded Cluster

1. Stop Balancer (and wait)

2. or no balancing window

3. Stop one config server (data R/O)

4. Backup Data (shards, config)

5. Restart config server

6. Resume Balancer

Page 23: Backup, Restore, and Disaster Recovery

Restore Example: Sharded Cluster

1. Dissimilar #shards to restore to

2. Different shard keys?

3. Selective restores

4. Consolidate shards

5. Changing addresses of config/shards

Page 24: Backup, Restore, and Disaster Recovery

Tips and Tricks

• mongodump/mongoresore– --oplog[Replay]– --objcheck/--repair– --dbpath– --query/--filter

• bsondump– inspect data at console

• lvm snapshot time/space trade-off– Multi ESB backup– clean up snapshots

Page 25: Backup, Restore, and Disaster Recovery

Senior Solution Architect, 10gen

Chad Tindel

#MongoDBDays

Thank You