Giter Site home page Giter Site logo

devluis / aws-ec2-instance-snapshots Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fborraccetti/aws-ec2-instance-snapshots

0.0 2.0 0.0 136 KB

AWS ec2 script that makes snapshot for each attached volume and rotate it each day, week and month deleting older

aws-ec2-instance-snapshots's Introduction

#aws-ec2-instance-snapshots

AWS ec2 script that makes snapshot for each attached volume and rotate it each day, week and month deleting older

This script makes;

  • a snapshot of each volume attached to the selected amazon aws ec2 instance.
  • check for snapshot older than KEEPFOR option ( -t ) seconds, 7 day default, and delete it
  • keep 1 snapshop for each day of the last week
  • keep 1 snapshot each week of the last month
  • keep 1 snapshot each month
  • All snapshot with description start equal to "AutoSnap:" will be rotated by this script

setup

$ git clone --recursive https://github.com/fborraccetti/aws-ec2-instance-snapshots $ cd aws-ec2-instance-snapshots/aws-sdk-for-php $ cp config-sample.inc.php config.inc.php

edit config.inc.php and set access key and secret key from aws account security

Look for your ec2 instance instance-id and go with php aws-ec2-instance-snapshots.php -i=YOURINSTANCEID -r=YOURREGION

Parameters and options

  • @param v

    The Instance ID of ec2 instance which you wish to manage.

  • @param r

    ( Optional ) Defaults to US-EAST-1. The region where the snapshots are held. Options include: us-e1, us-w1, us-w2, us-gov1, eu-w1, apac-se1, apac-ne1 AND sa-e1.

  • @param t

    (Optional) Default to 604 800 seconds ( 7 days ) The time in second to keep snapshot, snapshot older than will be deleted

  • @param o

    (Optional) Defaults to TRUE. No operation mode, it won't create any snapshots. use -n -o to lock any create and delete action

  • @param q

    (Optional) Defaults to FALSE. Quiet mode, no ouput.

  • @param n

    (Optional) Defaults to FALSE. No operation mode, it won't delete any snapshots. use -n -o to lock any create and delete action

Example usage:

Do a snapshot of each volumes attached to instance with id i-7ed55c04 and delete snapshot older than 600 seconds

 ubuntu@test:~/aws-ec2-instance-snapshots$ php aws-ec2-instance-snapshots.php -i=i-7ed55c04 -r=us-e1 -t 600

###Crontab Example:

00 00 * * * /usr/bin/php /home/fabio/admin/aws-ec2-instance-snapshots.php -i=i-7ed55c04

or 00 00 * * * /usr/bin/php /home/ubuntu/aws-ec2-instance-snapshots/aws-ec2-instance-snapshots.php -i=i-66e22c2d -r=eu-w1

###Thanks some code snippet taken from:

WARNING : USE AT YOU OWN RISK!!! This application will delete snapshots with description starting with "AutoSnap:" unless you use the -o option

aws-ec2-instance-snapshots's People

Contributors

fborraccetti avatar

Watchers

 avatar  avatar

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.