EC2 backup and restore

MongoDB Cloud Manager can automate making backups from EC2 volumes; and, since our data is in the cloud, why not use the Cloud Manager anyway?

If we can't use it for some reason, we can write a script to make backup by implementing the following steps:

  1. Assuming that we have journaling enabled (and we really should) and we have already mapped dbpath, containing data and journal files to a single EBS volume, we first need to find the EBS block instances associated with the running instance by using ec2-describe-instances.
  2. The next step is to find the logical volumes that dbpath of our MongoDB database is mapped to using lvdisplay.
  3. Once we have identified the logical devices from the logical volumes, we can use ec2-create-snapshot to create new snapshots. We need to include each and every logical device that maps to our dbpath directory.

To verify that our backups work, we need to create new volumes based on the snapshots and mount the new volumes there. Finally, the mongod process should be able to start mounting the new data, and we should connect by using MongoDB to verify these.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset