Last Updated: February 25, 2016
·
4.424K
· kjohnston

Using pgbackups-archive to automate archving Heroku backups to S3

I know that I'm not the first to tackle this problem and that other viable solutions exist. I looked at a number of them and came to the conclusion that I wanted to release a new gem that can see active maintenance and rely on as few dependencies as possible.

Heroku's recent changes to their databse offerings and manual vs. automated pgbackups leave two significant things to be desired:

  • The dev and basic plans don't support automated pgbackups natively.
  • pgbackups are stored and rotated by Heroku and many of us should really be archiving these backups to another location.

The pgbackups-archive gem addresses both of these points.

The pgbackups-archive gem

See the project on Github:
https://github.com/kjohnston/pgbackups-archive

The pgbackups:archive rake task that this gem provides will capture a pgbackup, wait for it to complete, then store it within the Amazon S3 bucket you specify. This rake task can be scheduled via the Heroku Scheduler, thus producing automated, offsite, backups.

The rake task will use pgbackups' --expire flag to remove the oldest pgbackup Heroku is storing when there are no free slots remaining.

You can configure retention settings at the Amazon S3 bucket level from within the AWS Console if you like.