Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have some Windows servers hosted on Amazon EC2. Some run Windows Server 2003 and other run Windows Server 2008. These are EBS-backed instances. Most of the instances also have some additional EBS-volumes attached.

We want to schedule a daily snapshot of the windows machines (and also the attached EBS-volumes) to S3 so that we have daily backups available.

One would think that this is a very common requirement and would be made available via the AWS Management Console, but alas, it is not. What approaches are available? How do I schedule daily snapshots on our Windows Servers?

There are several scripting examples available online for Linux, but not so much for windows. I have had a look at http://sehmer.blogspot.com/2011/04/amazon-ec2-daily-snapshot-script-for.html as well as https://github.com/ronmichael/aws-snapshot-scheduler. Has anyone used one of these approaches and does it work?

I have also considered a service like Skeddly which seems inexpensive at first glance but when you look at using it for several servers the price soon escalates to such a point where it seems a better option to create your own solution as you can then apply it to new servers in the future. With Skeddly we'll pay for each server.

How do we schedule daily snapshots of our windows instances?

share|improve this question
add comment

3 Answers

Amazon Web Services recently announced PowerShell command line tools for Windows and it's packaged along with their AWS Tools for .NET SDK.

The AWS Powershell tools make it quite easy to create a snapshot:

New-EC2Snapshot "vol-371acd04" -Description "My Snapshot"

And you can query your snapshots like this:

PS C:\Program Files (x86)\AWS Tools\PowerShell> Get-EC2Snapshot | more


SnapshotId  : snap-18be2b28
VolumeId    : vol-371acd04
Status      : completed
StartTime   : 2012-12-28T08:17:00.000Z
Progress    : 100%
OwnerId     : 383816850479
VolumeSize  : 30
Description : My Snapshot
OwnerAlias  :
Tag         : {}

Make sure you have the AWS Powershell tools installed and just create a scheduled task that uses a powershell script similar to the snippet above to schedule your snapshots and you should be good.

Updated to query for attached EBS volumes:

To query for EBS volumes attached to your instance and then snapshot each of them you could do something like this:

# Find my instance ID from the EC2 metadata
$myInstanceID = (New-Object System.Net.WebClient).DownloadString("http://169.254.169.254/latest/meta-data/instance-id")

# Query for volumes that are attached to my Instance Id
$volumes = (Get-EC2Volume).Attachment | where {$_.InstanceId -eq $myInstanceID } | Select VolumeId

# Iterate through these volumes and snapshot each of them
foreach ($volume in $volumes)
{
    New-EC2Snapshot $volume.VolumeId -Description "My Snapshot"
}
share|improve this answer
    
Thank you very much. This seems to be what I am looking for. Please just clarify: it seems like the New-EC2Snapshot command will only take a snapshot of a specific volume. In my case I have the Instance and it also has some EBS-volumes attached. How would I take a full snapshot of the entire instance including the root device and the attached EBS volumes? –  Stanley Jan 28 '13 at 9:42
    
@Stanley updated to query for the EBS volumes attached to your instance and snapshot each –  Ameer Deen Jan 28 '13 at 11:36
    
I see thank you. That means that there will be separate snapshots for each volume. I just want to understand the implication of this: In case of failure, how would I bring up a replacement instance? The snapshots for the EBS root volume and the individual mounted EBS volumes will all be separate. How would I bring up a replacement instance with the mounted drives from the different snapshots? –  Stanley Jan 28 '13 at 15:02
    
Why can you not set this up via the EC2 dashboard? For people who are not overly confident with the scripts? –  leen3o Oct 4 '13 at 7:21
add comment

You can write a script that talks to the EC2 API to schedule those snapshots. It can be run on one of your existing instances or you could set up a small linux instance for this purpose on a t1.micro whose sole function is to kick off the snapshots for the Windows hosts. The script could be put on the linux host as a cron job to run daily at the time you choose.

The first link is an example of scripting that from a Windows host and it could easily be automated with Scheduled Tasks in Windows.

I have not used the application you linked on your second link.

share|improve this answer
    
Could you perhaps give some more detail? I realize that the solution would probably be for me to write some kind of script but this knowledge on it's own isn't sufficient for me to solve the problem, unfortunately. Do you perhaps have a link or sample of the scripts that you are referring to? –  Stanley Nov 28 '12 at 14:49
    
The one you linked from your question will actually work fine. Are you familiar with the AWS API Command-Line tools at all? –  Nathan V Nov 28 '12 at 15:07
add comment

Follow the link below,

http://jayaraj.sosblogs.com/The-first-blog-b1/AWS-Automated-EBS-Snapshot-Script-b1-p3.htm

Hope this helps. :)

Note: This script is only for linux

share|improve this answer
1  
This does not help. As mentioned in the question my question is for Windows. I even mention that I've seen some scripting examples in Linux but that these are not useful. I'd appreciate if you have some help for Windows please. –  Stanley Nov 28 '12 at 14:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.