Created
March 14, 2017 09:50
-
-
Save ErvalhouS/1446da34c7476ba488a973370f41a4d7 to your computer and use it in GitHub Desktop.
Get latest Heroku database state, dump and apply on localhost Postgres
This file contains hidden or 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
namespace :latest do | |
desc "rake 'latest:db' Get last state from the production database" | |
task db: :environment do | |
Rake::Task["db:drop"].execute | |
Rake::Task["db:create"].execute | |
system( "heroku pg:backups:capture --app <YOUR APP NAME>" ) | |
system( "curl -o latest.dump `heroku pg:backups public-url`" ) | |
system( "pg_restore --verbose --clean --no-acl --no-owner -d <YOUR DEVELOPMENT DATABSE NAME> latest.dump" ) | |
Rake::Task["db:migrate"].execute | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment