A few days back, I needed to write a rake task to backup my database daily and store it in S3. Googling a little bit, I found out there posts like
this one, that teach you how to do it and even a
gem that simplifies your work. I also found out that Heroku has an addon called
PGBackups to do exactly that, holding until 7 daily backups. So the only thing I needed to do was transfering the generated backup to S3 (we want to retain up until a year of backups). Slicing the transfering chunk of code from one of the available posts, I created this
rake task
That transfers the latest backup to S3. The interesting part of this code is this line
public_url = "heroku pgbackups:url --app <heroku_app_name>"
That publishes temporarily the url of the latest backup to be transfered.
Isn't it cool Heroku? I love it.