Giter Club home page Giter Club logo

aws-ec2-rsnapshot's Introduction

AWS EC2 Snapshot Backup

Installation

That script could be used on both Linux and Windows instances.

For Linux you will need to install:

mkdir /srv
cd /srv
git clone https://github.com/sormy/aws-ec2-rsnapshot.git
cd aws-ec2-rsnapshot
git checkout {version}
node install
ln -s /srv/aws-ec2-rsnapshot/aws-ec2-rsnapshot.js /usr/local/bin/aws-ec2-rsnapshot

For Windows you will need to install:

...

Usage

Usage: node aws-ec2-rsnapshot.js <snapshot-prefix> <snapshot-retention> <volume-id> [run-before]

Params:

  • snapshot-prefix: something like srv1.domain.com/daily/data
  • snapshot-retention: number of snapshots to keep
  • volume-id: volume id to make snapshot from it
  • before-command: run command before, perfect to sync filesystem before snapshot

Environment variables

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_CONFIG_FILE
  • AWS_DEFAULT_PROFILE
  • AWS_DEFAULT_REGION

Please look on http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment for more details.

Example

For example, we would like to backup root voume and store 7 daily snapshots and 8 weekly snapshots.

Here we assume that credentials and default region are stored in /root/.aws and cron tasks run from root.

File: /etc/cron.daily/aws-ec2-rsnapshot

#!/bin/bash

export HOME=/root
output=$(aws-ec2-rsnapshot server.com/daily/root 7 vol-12345678 sync)
if [ $? != 0 ]; then
    echo $output
fi

File: /etc/cron.weekly/aws-ec2-rsnapshot

#!/bin/bash

export HOME=/root
output=$(aws-ec2-rsnapshot server.com/weekly/root 8 vol-12345678 sync)
if [ $? != 0 ]; then
    echo $output
fi

Files below should have executable bit:

chmod +x /etc/cron.daily/aws-ec2-rsnapshot
chmod +x /etc/cron.weekly/aws-ec2-rsnapshot

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.