Created
March 4, 2014 01:32
-
-
Save derencius/9338535 to your computer and use it in GitHub Desktop.
heroku db download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "thor" | |
class MyCLI < Thor | |
desc "download", "production database" | |
def download(remote) | |
puts "Downloading... #{remote}" | |
system "heroku pgbackups:capture --expire --remote #{remote}" | |
system "curl `heroku pgbackups:url --remote #{remote}` -o #{remote}.dump" | |
puts "Done!" | |
end | |
desc "restore", "load dump in dev database" | |
def restore(remote, db) | |
system "ps ax | grep postgres: | grep #{db} | cut -c1-8 | xargs kill" | |
system "dropdb #{db}; createdb #{db}" | |
system "pg_restore --verbose --clean --no-acl --no-owner -d #{db} #{remote}.dump" | |
system "touch tmp/restart.txt" | |
end | |
end | |
MyCLI.start(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment