Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Backing up and restoring Postgres databases using S3 for automation

Project Description

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


* 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:


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

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

print "Restoring from most recent backup..."

print "Restoring from most recent backup using a string..."
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Elefant-0.0.6.tar.gz (4.0 kB) Copy SHA256 Checksum SHA256 Source Jul 10, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting