heroku / heroku.rb

DEPRECATED! Official Heroku Ruby Legacy API wrapper
161 stars 41 forks source link

How do I run pgbackups:capture via API? #72

Open rkh opened 10 years ago

rkh commented 10 years ago

We currently use the heroku-api gem for continuous deployment from Travis CI and have our users asking for the ability to run pgbackups:capture before deploying. I have not found a way to do this short of installing the heroku toolbelt. :/

Maybe I'm just missing something.

will commented 10 years ago

The only supported way to use pgbackups is through the toolbelt cli. It doesn't have an official, supported API. Of course the source is open and you can figure out how to use it. https://github.com/heroku/heroku/blob/master/lib/heroku/client/pgbackups.rb#L12-L27 is a good starting point.

Being an undocumented API there are a lot of warts. For example for this to work the x_heroku_gem_version header is required to be something greater than 2.26.0. Also the TO and FROM parts need to be formatted the same way that the toolblet would set. This would be mostly unfortunate if you do it wrong, and then people open support tickets to us.

Also things might change without notice, etc etc.

It's up to you if the tradeoff of not needing to vendor the CLI vs unstable/unsupported going away or breaking is worth it. For what it's worth, I'd prefer you went with the toolbelt, but I'm not going to actively stop you from doing whatever.

This is something that we'd like to have an supported API for, but simply don't today. :/

Regardless of how you do this, you have to then be careful if people are at their backup limits. Are you going to expire old backups on their behalf? Will they consent to you deleting some of their backups?

rkh commented 10 years ago

Thanks for the input. I guess I would refrain from using a private API, esp when it includes such rough edges.

We would not to this fully automatically, instead we would add "magic" commands like we do it for restarting the application already, so it would basically be up to our users.