GithubHelp home page GithubHelp logo

wibru / osc-bsu-backup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from outscale/osc-bsu-backup

0.0 0.0 0.0 58 KB

cli tool to easily schedule instance snapshots and rotate it on Outscale Cloud

License: BSD 3-Clause "New" or "Revised" License

Makefile 2.21% Python 97.48% Dockerfile 0.31%

osc-bsu-backup's Introduction

osc-bsu-backup

Introduction

cli tool to easily schedule instance snapshots and rotate it on Outscale Cloud

Install

python3 setup.py install

How to build

make develop

How to tests

make unit
#you must have an account on the region eu-west-2 from Outscale
#~/.aws/credentials
[default]
aws_access_key_id = NABUAZEYBFZEBAZF6554631
aws_secret_access_key = AIGFABUIBZF10354AZF3A1CZ53A

make integration

Usage

INFO:osc_bsu_backup.cli:osc_bsu_backup: 0.0.4
usage: osc-bsu-backup [-h] [--instance-by-id INSTANCE_ID]
                      [--instances-by-tags INSTANCES_TAGS [INSTANCES_TAGS ...]]
                      [--volume-by-id VOLUME_ID]
                      [--volumes-by-tags VOLUMES_TAGS [VOLUMES_TAGS ...]]
                      [--rotate ROTATE] [--rotate-by-days ROTATE_DAYS]
                      [--rotate-only] [--region REGION] [--endpoint ENDPOINT]
                      [--profile PROFILE] [--client-cert CLIENT_CERT]
                      [--debug]

osc-ebs-backup: 0.0.4

optional arguments:
  -h, --help            show this help message and exit
  --instance-by-id INSTANCE_ID
                        instance to backup
  --instances-by-tags INSTANCES_TAGS [INSTANCES_TAGS ...]
                        instances tags to look for, use the format Key:Value.
                        Can be used multiple times
  --volume-by-id VOLUME_ID
                        volume to backup
  --volumes-by-tags VOLUMES_TAGS [VOLUMES_TAGS ...]
                        volumes tags to look for, use the format Key:Value.
                        Can be used multiple times
  --rotate ROTATE       retention for snapshot
  --rotate-by-days ROTATE_DAYS
                        retention for snapshot, delete snapshots if there are
                        older than N days
  --rotate-only         only rotate snapshots create by osc-bsu-backup
  --region REGION       region
  --endpoint ENDPOINT   endpoint
  --profile PROFILE     aws profile to use, ~/.aws/credentials. Don't set to
                        use environment variables
  --client-cert CLIENT_CERT
                        for TLS client authentication
  --debug               enable debug

How to use

this tool is intend to be use with cron and aws profile, here is an example of setup

this cron will backup every instance that has the tag autosnapshot=Yes it will only keep the seventh more recent snapshots

#crontab -l
5 2 * * * osc-bsu-backup --profile default --region eu-west-2 --rotate 7 --instances-by-tags 'autosnapshot:Yes'
7 2 * * * osc-bsu-backup --profile default --region eu-west-2 --rotate 7 --client-cert /home/remi/test1.pem --instances-by-tags 'autosnapshot:Yes'
4 2 * * * osc-bsu-backup --profile default --region eu-west-2 --rotate 7 --client-cert /home/remi/test1.pem --instances-by-tags 'autosnapshot:Yes' --instances-by-tags 'Name:test1'
#~/.aws/credentials
[default]
aws_access_key_id = NABUAZEYBFZEBAZF6554631
aws_secret_access_key = AIGFABUIBZF10354AZF3A1CZ53A

Environment variables could be used for authentication instead of aws profile. Set these environment variables (the --profile option should not be set):

AWS_ACCESS_KEY_ID=NABUAZEYBFZEBAZF6554631
AWS_SECRET_ACCESS_KEY=AIGFABUIBZF10354AZF3A1CZ53A

Eim policy

{
    "Statement": [
        {
            "Action": [
                "ec2:DescribeKeyPairs"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:CreateSnapshot"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:DescribeInstances"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:DescribeVolumes"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:DescribeSnapshots"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:DeleteSnapshot"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        }
    ]
}

osc-bsu-backup's People

Contributors

outscale-rjt avatar wibru avatar jerome-jutteau 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.