Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
#MongoDBDaysBackup, Restore, andDisaster RecoveryChad TindelSenior Solution Architect, 10gen
Agenda• Backup• Recover• Disaster recovery• Know your options
Backup
What’s the most importantthing about making backups?Restoring them
If you dont ensure thatyour backups can berestored, theres nopoint in doing backups
Backup Options• Mongodump• Copy files• Snapshot disk
mongodump• Dumps collections to *.bson files• Mirrors your structure• Can be run in live or offline mode• --dbpath for dir...
mongodump$ mongodump --helpExport MongoDB data to BSON files.options: --help              produce help message -v [ --verb...
Restore
mongorestore• mongorestore• --oplogReplay replay oplog last PIT
File System• Must use journaling• File system snapshot• Copy /data/db files• Seriously, always use journaling
File System• fsyncLock flush and stop accepting writes• Dont forget to fsyncUnlock
File System• Entire database• Backup files will be large• Fastest way to create a backup• Fastest way to restore a backup
Restore Options• Entire database• Replay Oplog• Selected dbs, collections
Disaster Recovery
Replica SetsDisaster Avoidance
Disaster Recovery > rs.conf() {"_id" : "replSetName","version" : 3,"members" : [  {    "_id" : 0,    "host" : "myhost1.dns...
Avoid single point of failure
Disaster Recovery• Redundancy• Multiple Datacenters• Multiple Regions
Disaster Recovery• Recovery (restore) time• Replacement   – Machine   – Component (disk, memory, etc)   – Cluster• Configu...
Examples
Backup Example: ShardedCluster1. Stop Balancer (and wait)2. or no balancing window3. Stop one config server (data R/O)4. B...
Restore Example: ShardedCluster1. Dissimilar #shards to restore to2. Different shard keys?3. Selective restores4. Consolid...
Tips and Tricks• mongodump/mongoresore   – --oplog[Replay]   – --objcheck/--repair   – --dbpath   – --query/--filter• bson...
#MongoDBDaysThank YouChad TindelSenior Solution Architect, 10gen
Upcoming SlideShare
Loading in …5
×

Backup, Restore, and Disaster Recovery

1,449 views

Published on

  • Be the first to comment

Backup, Restore, and Disaster Recovery

  1. 1. #MongoDBDaysBackup, Restore, andDisaster RecoveryChad TindelSenior Solution Architect, 10gen
  2. 2. Agenda• Backup• Recover• Disaster recovery• Know your options
  3. 3. Backup
  4. 4. What’s the most importantthing about making backups?Restoring them
  5. 5. If you dont ensure thatyour backups can berestored, theres nopoint in doing backups
  6. 6. Backup Options• Mongodump• Copy files• Snapshot disk
  7. 7. 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
  8. 8. mongodump$ 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 programs 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
  9. 9. Restore
  10. 10. mongorestore• mongorestore• --oplogReplay replay oplog last PIT
  11. 11. File System• Must use journaling• File system snapshot• Copy /data/db files• Seriously, always use journaling
  12. 12. File System• fsyncLock flush and stop accepting writes• Dont forget to fsyncUnlock
  13. 13. File System• Entire database• Backup files will be large• Fastest way to create a backup• Fastest way to restore a backup
  14. 14. Restore Options• Entire database• Replay Oplog• Selected dbs, collections
  15. 15. Disaster Recovery
  16. 16. Replica SetsDisaster Avoidance
  17. 17. 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" }]}
  18. 18. Avoid single point of failure
  19. 19. Disaster Recovery• Redundancy• Multiple Datacenters• Multiple Regions
  20. 20. Disaster Recovery• Recovery (restore) time• Replacement – Machine – Component (disk, memory, etc) – Cluster• Configuration (reconfiguration)
  21. 21. Examples
  22. 22. Backup Example: ShardedCluster1. Stop Balancer (and wait)2. or no balancing window3. Stop one config server (data R/O)4. Backup Data (shards, config)5. Restart config server6. Resume Balancer
  23. 23. Restore Example: ShardedCluster1. Dissimilar #shards to restore to2. Different shard keys?3. Selective restores4. Consolidate shards5. Changing addresses of config/shards
  24. 24. 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
  25. 25. #MongoDBDaysThank YouChad TindelSenior Solution Architect, 10gen

×