Automated Windows Server Backups on AWS EC2

by noahlh on July 2, 2014

I recently replaced an aging (and brittle…and risky) physical Windows box in our office with an AWS-hosted EC2 instance of Windows Server 2012 R2 and needed a good way to make sure the instance got backed-up nightly.

The original box was a simple Ubuntu server running VirtualBox-hosted Windows 7.  We had QuickBooks Enterprise running there, and the 3 folks who worked on accounting stuffs for us would login via Remote Desktop, do their thing, and sign off each night.  That box was running Dropbox and, in theory, should have automatically backed-up our QuickBooks file as soon as the file closed each night.

The problem, however, is that A) Dropbox isn’t daemon/service-based, so if the main user account got logged off for some reason, Dropbox would stop running, and B) Dropbox would only sync when the QuickBooks file was “closed”, which means all users had to remember to both close the file and log off each night.  In practice, this didn’t happen.

I felt like that box was a ticking time bomb of non-backed-up financial misery and was dreading getting that call:  ”So the hard drives are making a weird sound and I can’t login to QuickBooks – what do I do?”

The solution:  Move everything to the cloud.  I spun up an Amazon EC2 Windows Server instance, attached some storage, setup RDS (a bit of a process which is the scope of another post), and got QuickBooks running on that server.

The next problem:  Amazon EC2 is truly “infrastructure”, which means there isn’t just a simple “automated backup” button (like there is with Microsoft Azure and most linux-based VPS hosts).  So I had to roll my own.

The best solution I came up with was to run a set of PowerShell scripts to automate the EBS snapshot process nightly.  Based on this excellent post:

http://messor.com/aws-disaster-recovery-automation-w-powershell/

The issue with those scripts is that they were written for an old version of the AWS SDK (v1.0).  So I dug into the Windows PowerShell ISE, fired up the debugger, and got everything working with the latest version.

Lo and behold, an updated set of scripts.  Enjoy!

https://github.com/noahlh/aws-automated-backup-powershell

2 comments

What a wonderful piece of work! Thank you not only for doing it and making it public, but also putting it on Github!

Do the scripts do anything to ensure a consistent snapshot e.g. any kind of VSS? If not. have you had any problems with backup integrity?

What would be the restore process? EC2 is a pain that you can’t just create a ‘blank’ Windows instance and attach an EBS volume as its root in the way you can with Linux instances. How have you solved that?

Cheers,
Gavin.

Before now I’ve just had to launch a new Windows EC2 instance, and ‘stop’ it as soon as it moves to

by Gavin Hamill on July 8, 2014 at 3:55 pm. #

Hi Gavin — no, no verification of consistency — it’s just a raw snapshot output. I haven’t had any issues so far — have restored once and had zero problems. But I imagine that putting some consistency-checking in there would be a good thing (a bit beyond my know-how right now though).

The restore process for me is pretty straightforward — you use the same instance and create a new EBS volume from the snapshot(s), then assign the correct device path on AWS (i.e. /dev/sda1, xvdb, etc.) and attach the new volumes that were built from the snapshots. All seems to work fine for me. See here:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-restoring-volume.html

by noahlh on July 30, 2014 at 2:08 pm. #