Git Product home page Git Product logo

cw_s3's Introduction

Cameron & Wilding - S3 tool

Requirements

  • python 2.x (>=2.6)
  • pip
  • boto3
  • argparse

Installation

Virtual Python environment (recommended)

pip install virtualenv

Modules

pip install boto3
pip install argparse

Credentials

  • mkdir ~/.aws
  • create a file in ~/.aws/credentials with the content:
[default]
aws_access_key_id = ID
aws_secret_access_key = SECRET
  • add the necessary AWS credentials

Usage

Direct Python API

Upload file

import s3

package = s3.S3UploadPackage(
    file_path="/PATH/TO/FILE",
    project="my_project",
    upload_type=s3.S3UploadType.DB_DUMP,
    rotation_policy=s3.S3RotationPolicy.weekly()
)

s = s3.S3Handler(bucket_name=BUCKET_NAME)
s.upload(package)

Runners

Ping (health check)

Print out "Works!" if it's accessible:

$> python s3_ping.py BUCKETNAME && echo "Works!"

Upload file

$> python s3_upload.py -h

usage: s3_upload.py [-h] [--type TYPE] [--month] [--week] [--day] [--hour]
                    B F P

Upload file to S3 bucket.

positional arguments:
  B            bucket name
  F            file to upload
  P            project it belongs to

optional arguments:
  -h, --help   show this help message and exit
  --type TYPE  type of the upload, possible values: asset, database, files
  --month      add monthly rotation policy
  --week       add weekly rotation policy
  --day        add daily rotation policy
  --hour       add hourly rotation policy

$> python s3_upload.py my_bucket ~/Desktop/dump.sql.gz my_project --type database --day --month

cw_s3's People

Contributors

itarato avatar

Stargazers

Rafal W. avatar

Watchers

James Cloos 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.