CaseyLabs / aws-ec2-ebs-automatic-snapshot-powershell

Powershell script for Automatic EBS Snapshots and Cleanup on Amazon Web Services (AWS). Created by CaseyLabs.
http://www.caseylabs.com
GNU General Public License v2.0
25 stars 19 forks source link

aws-ec2-ebs-automatic-snapshot-powershell

Powershell script for Automatic EBS Snapshots and Cleanup on Amazon Web Services (AWS) EC2

Written by [AWS Consultants - Casey Labs Inc.] (http://www.caseylabs.com)

Casey Labs - Contact us for all your Amazon Web Services Consulting needs!

===================================

How it works: These scripts will:

Pull requests greatly welcomed!

===================================

REQUIREMENTS

IAM: This script requires that an IAM User or IAM Role be created with the following policy attached:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1426256275000",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateSnapshot",
                "ec2:CreateTags",
                "ec2:DeleteSnapshot",
                "ec2:DescribeSnapshots",
                "ec2:DescribeVolumes",
                "ec2:DescribeInstances"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}


AWS CLI: This script requires the AWS CLI tools to be installed on the target Windows instance.

C:\Users\Administrator> aws configure

AWS Access Key ID: (Enter in the IAM credentials generated above.)
AWS Secret Access Key: (Enter in the IAM credentials generated above.)
Default region name: (The region that this instance is in: i.e. us-east-1, eu-west-1, etc.)
Default output format: (Enter "text".)


INSTALL SCRIPT AS A SCHEDULED TASK

1) [Download the scripts from Github] (https://github.com/CaseyLabs/aws-ec2-ebs-automatic-snapshot-powershell/archive/master.zip)

2) Extract the zip contents to C:\aws on your Windows Server

3) Next, open Task Scheduler on the server, and create a new task that runs:

powershell.exe -ExecutionPolicy Bypass -file "C:\aws\1-start-ebs-snapshot.ps1"

...on a nightly basis.

===================================

TROUBLESHOOTING

If you setup the AWS CLI under a Windows user account other than the local Administrator, you will need to edit the file "2-run-backup.cmd", and change the USERPROFILE path.

For example, let's say that you've configured the AWS CLI credentials under the Windows user account "myadmin". You will need to: