Backup, Restore, and Disaster Recovery

1,257 views
1,186 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,257
On SlideShare
0
From Embeds
0
Number of Embeds
600
Actions
Shares
0
Downloads
41
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Needs more content?
  • 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

    ×