Restoring historic files on AWS EC2 Instances

In order to do this you will need access to the AWS Console. you will need permission to restore snapshots and mount volumes.

So Why would we need to recover old files?

Well, the most common reason is for historic SQL Server backups. if you need to recover a database from a backup which was taken last week, it’s unlikely that .bak file will still be on disk. now with it being in AWS, disks are backed up via a snapshot at a particular time in the day. (no more of this restore from tape nonsense!)

So how do we do it?

Find your Instance ID (This is the AWS Name for the EC2 Instance you’re running).

Go To: Services > EC2 > Instances

You should See your EC2 Instances name with an Instance ID (Note this down)

Click on the Instance ID then go to Volumes. Note down the Volume ID for the disk which the file you need to recover is on.

in the left hand navigation pane, go to Elastic Block Store > Snapshots

In the top Filter Section, Filter on Volume ID

Now it’s a case of scrolling through the Snapshots, finding the date you require. Right Click on the Snapshot, Click Create Volume.

This will run through a volume creation wizard, you should be able to just click next and okay. this will also give you a new Volume ID (Note this down)

Under Elastic Block Store > Volumes you should see your new volume. Right Click the volume, and Attach Volume to your EC2 Instance. this will then attach the volume as a disk on your server.

Now you need to Log on to your Server go to Disk Management you should see a new disk in an Offline state. Right Click and Bring Online Assign the disk a drive letter that isn’t in use. You should see the disk in My Computer. this new disk will have all the files on when the snapshot was taken. (Hopefully including the files you’re looking to restore!)

Phew! Easy right?

Don’t forget to clean up the Volume once you’re done. you don’t want to be charged for the additional storage costs for mounting a disk which isn’t used!

When you’re done, go to Elastic Block Store > Volumes > Right Click the recovered volume > Detach Volume > Right Click again > Delete Volume

BE CAREFUL! YOU DONT WANT TO DETACH OR DELETE A DISK THAT IS IN USE! MAKE SURE YOU’RE WORKING WITH THE ID’S WHICH YOU’VE NOTED DOWN