Code Monkey home page Code Monkey logo

elefant's Introduction

elefant

Allows you to backup and restore your Heroku database using your own private storage in S3. This allows circumventing the backup limit in Heroku plans and also gives peace of mind that your data is backed up somewhere else besides Heroku.

Tested only on Unix machines and Heroku Postgres 9.4.

Installation

pip install elefant

Elefant's only dependencies are boto in Python and, of course, postgres (use of pg_restore).

Usage

Steps:

  • Ensure AWS credentials are set up in environment variables for boto
  • Ensure heroku is logged in with $ heroku login

Elefant will create an S3 bucket for you so long as it is not taken and your AWS user has the permissions to do so.

Backup Format

You'll give Elephant both the name of your S3 bucket and the name of your Heroku app upon instantiation, and it will in turn store backup dumps with the following format:

<S3-BUCKET>/<HEROKU-APP-NAME>__%Y_%m_%d-%H_%M_%S.dump

where the formatting is standard Python date formatting.

The filetype is a Postgres dump file, not a SQL text dump.

Example

from elefant import Elefant

# create Elefant object, passing in the Heroku app name and backups bucket
eft = Elefant("myapp", "mybucket")

print "Making backup, uploading to S3, and then deleting from Heroku..."
eft.backup() 

print "Availiable backups:"
backups = eft.backups 
for b in backups: 
	print b.name

print "Restoring from most recent backup..."
eft.restore(b) 

print "Restoring from most recent backup using a string..."
eft.restore(b.name)

elefant's People

Contributors

worldveil 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.