heroku-postgres
This provides a Ruby client to Heroku's Postgres service. It's been partially extracted from the Heroku command line client as it's otherwise not documented.
It was primarily built to automate creating backups for usage elsewhere. It's initially limited to just being able to do this, so if there's something missing, open an issue. It's also pretty lacking in tests for similar reasons.
Installation
Add this line to your application's Gemfile:
gem 'heroku-postgres'
And then execute:
$ bundle
Or install it yourself as:
$ gem install heroku-postgres
Usage
require 'heroku/postgres'
# login (return a client object, but you don't need that directly)
Heroku::Postgres.login('username', 'password')
# find the database by app name and database name
db = Heroku::Postgres.find('app-name', 'db-name')
# have a look at the current backups
db.backups
# => [<Heroku::Postgres::Backup id=abc>]
# capture a backup, waiting for completion
# optionally, pass true to poll until complete
backup = db.capture_backup(true)
# or, pass a block to monitor the response whilst it's created
backup = db.capture_backup(true) do |backup|
puts backup
end
# generate a public url so you can fetch the file
backup.public_url
Contributing
- Fork it ( https://github.com/nickcharlton/heroku-postgres/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Author
Copyright (c) 2015 Nick Charlton nick@nickcharlton.net.