Giter Club home page Giter Club logo

heroku_cloud_backup's Introduction

Heroku Cloud Backup

The heroku_cloud_backup gem adds a rake task to your project that will take backups stored with Heroku's PGBackup addon and upload them to the cloud.

Installation

It's recommended that you use this gem in conjunction with the heroku_backup_task gem. heroku_backup_task adds a rake tasks that will create a fresh database capture and expire the oldest backup if you're at your capture limit.

First, you need to enable the Heroku PGBackups addon:

heroku addons:add pgbackups:basic

If you want this to run daily, you'll need to enable the Heroku cron addon:

heroku addons:add cron:daily

For Rails 3 and later, add this to your Gemfile:

gem 'heroku_backup_task'
gem 'heroku_cloud_backup'

For Rails 2.1 and later, add this to your in your environment.rb:

config.gem 'heroku_backup_task'
config.gem 'heroku_cloud_backup'

In your Rakefile:

require "heroku_backup_task"
require "heroku_cloud_backup"
task :cron do
  HerokuBackupTask.execute
  HerokuCloudBackup.execute
end

Usage

The first thing you'll want to do is configure the addon.

HCB_PROVIDER (aws, rackspace, google) - Add which provider you're using. Required

heroku config:add HCB_PROVIDER='aws' # or 'google' or 'rackspace'

HCB_BUCKET (alphanumberic characters, dashes, period, underscore are allowed, between 3 and 255 characters long) - Select a bucket name to upload to. This the bucket or root directory that your files will be stored in. If the bucket doesn't exist, it will be created. Required

heroku config:add HCB_BUCKET='mywebsite'

HCB_PREFIX (Defaults to "db") - The direction prefix for where the backups are stored. This is so you can store your backups within a specific sub directory within the bucket. heroku_cloud_backup will also append the ENV var of the database to the path, so you can backup multiple databases, by their ENV names. Optional

heroku config:add HCB_PREFIX='backups/pg'

HCB_MAX (Defaults to no limit) - The number of backups to store before the script will prune out older backups. A value of 10 will allow you to store 10 of the most recent backups. Newer backups will replace older ones. Optional

heroku config:add HCB_MAX=10

Depending on which provider you specify, you'll need to provide different login credentials.

For Amazon:

heroku config:add HCB_KEY1="aws_access_key_id"
heroku config:add HCB_KEY2="aws_secret_access_key"

For Rackspace:

heroku config:add HCB_KEY1="rackspace_username"
heroku config:add HCB_KEY2="rackspace_api_key"

For Google Storage:

heroku config:add HCB_KEY1="google_storage_secret_access_key"
heroku config:add HCB_KEY2="google_storage_access_key_id"

You can run this manually like this:

heroku rake heroku_backup
heroku rake heroku:cloud_backup

Restoring a backup

I would recommend you create a temporarily public url from your cloud storage. I do this with Cyberduck. It has a neat feature where you can right click on a file and it'll generate temporarily accessible urls to that file, with the auth params for it. So once you have that url you can store like this:

heroku pgbackups:restore 'http://my-bucket-name.s3.amazonaws.com/db/DATABASE_URL/2011-06-09-014500.dump?authparameters'

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2011 Jack Chu. See LICENSE for details.

heroku_cloud_backup's People

Contributors

kamui avatar

Stargazers

 avatar

Watchers

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