Skip to content

Instantly share code, notes, and snippets.

@searls
Created December 19, 2020 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save searls/6c57146431c791d141ae64e2358aeccf to your computer and use it in GitHub Desktop.
Save searls/6c57146431c791d141ae64e2358aeccf to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# This blog post has helped a lot of folks figure out how to pull down their production database
# from Heroku without bringing their application to a screeching halt.
# https://blog.testdouble.com/posts/2019-11-12-downloading-large-heroku-postgres-backups/
#
# Here's a silly little script that will do it all for you. (YMMV, don't actually use this, etc)
require "date"
out = `heroku addons:create heroku-postgresql:standard-0 --fast --fork DATABASE_URL`
addon = out.match(/(\S+) is being created in the background/)[1]
`heroku pg:wait`
`heroku pg:pull #{addon} kamesame_production-#{Date.today}`
`heroku addons:remove #{addon} --confirm kamesame-production`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment