Code Monkey home page Code Monkey logo

aws-lambda-backup's Introduction

AWS Lambda Backup

AWS Lambda Backup is a script to create and remove snapshots of EBS volumes.

โš ๏ธ This project is now archived because it has been superseded by AWS Backup.

Features

  • Create daily, weekly, monthly and yearly snapshots based on your individual configuration
  • Automatically clean up old snapshots

Configuration

Just add a Tag named LambdaBackupConfiguration to your EC2 instances with the following format:

[RetentionDaily],[RetentionWeekly],[RetentionMonthly],[RetentionYearly]

Examples:

  • 7,4,12,1 to have 7 daily, 4 weekly, 12 monthly and 1 yearly backup
  • 7,0,3,0 to have 7 daily, 3 monthly backups
  • 0,4,0,0 to have 4 weekly backups

Only one backup per day will be created (due to parallel snapshot limitations of AWS). Weekly backups will be created on Sunday, monthly backups on 1st day of the month and yearly backups on 1st of January. If you specify 0 for a weekly, monthly or yearly Retention, a backup for the next group (monthly instead of yearly, weekly instead of monthly and daily instead of weekly) will be made.

Installation

Via Terraform

This project is a Terraform module. Reference module by adding the following to your terraform configuration:

module "aws-lambda-backup" {
  source  = "${path-to-modules}/aws-lambda-backup"
}

Initialize module by (re-)initializing your terraform project:

terraform init

Apply changes to terraform configuration:

terraform plan -out terraform.tfplan

Check if everything is ok and then call:

terraform apply terraform.tfplan

Via CloudFormation

TBD

Manually

  1. Create an IAM role for AWS Lambda and add the following inline policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "ec2:CreateSnapshot",
                "ec2:CreateTags",
                "ec2:DeleteSnapshot",
                "ec2:DescribeInstances",
                "ec2:DescribeSnapshots"
            ],
            "Resource": "*"
        }
    ]
}
  1. Create a Lambda function
  • Select blueprint
    • Select "Blank Function"
  • Configure triggers
    • Select "CloudWatch Events - Schedule"
    • Choose "rate(1 day)"
    • Enable trigger
  • Configure function
    • Enter name
    • Select "Python 3.6" from the Runtime dropdown
    • Copy the source code from ebs-backup.py to code window
    • Check that Handler is "lambda_function.lambda_handler"
    • Choose the previously created IAM role
  1. Check the logs

Check the logs in the CloudWatch Logs area.

Copyright

Copyright 2017 Oliver Siegmar

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

aws-lambda-backup's People

Contributors

osiegmar avatar reinaldocoelho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aws-lambda-backup's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.