backup, restore, and disaster recovery
DESCRIPTION
TRANSCRIPT
![Page 1: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/1.jpg)
Senior Solution Architect, 10gen
Chad Tindel
#MongoDBDays
Backup, Restore, and Disaster Recovery
![Page 2: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/2.jpg)
Agenda
• Backup
• Recover
• Disaster recovery
• Know your options
![Page 3: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/3.jpg)
Backup
![Page 4: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/4.jpg)
What’s the most important thing about making backups?Restoring them
![Page 5: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/6.jpg)
Backup Options
• Mongodump
• Copy files
• Snapshot disk
![Page 7: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/8.jpg)
$ 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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/9.jpg)
Restore
![Page 10: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/10.jpg)
mongorestore
• mongorestore
• --oplogReplay replay oplog last PIT
![Page 11: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/11.jpg)
File System
• Must use journaling
• File system snapshot
• Copy /data/db files
• Seriously, always use journaling
![Page 12: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/12.jpg)
File System
• fsyncLock flush and stop accepting writes
• Don't forget to fsyncUnlock
![Page 13: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/14.jpg)
Restore Options
• Entire database
• Replay Oplog
• Selected dbs, collections
![Page 15: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/15.jpg)
Disaster Recovery
![Page 16: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/16.jpg)
Replica SetsDisaster Avoidance
![Page 17: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/17.jpg)
> 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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/18.jpg)
Avoid single point of failure
NEW IMAGE?
![Page 19: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/19.jpg)
Disaster Recovery
• Redundancy
• Multiple Datacenters
• Multiple Regions
![Page 20: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/20.jpg)
Disaster Recovery
• Recovery (restore) time
• Replacement– Machine– Component (disk, memory, etc)– Cluster
• Configuration (reconfiguration)
![Page 21: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/21.jpg)
Examples
![Page 22: Backup, Restore, and Disaster Recovery](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/22.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/23.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/24.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022081414/54b6f0e84a795902588b45ed/html5/thumbnails/25.jpg)
Senior Solution Architect, 10gen
Chad Tindel
#MongoDBDays
Thank You