Created
July 30, 2016 14:05
-
-
Save dennis-best/55975396515d6ee32f0fc3eea8160f72 to your computer and use it in GitHub Desktop.
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
namespace :db do | |
desc "Syncs local database with production" | |
task :sync do | |
puts 'Syncing local database with production...' | |
db_config = Rails.configuration.database_configuration | |
database_name = db_config['development']['database'] | |
begin | |
`heroku pg:backups capture` | |
`curl -o latest.dump \`heroku pg:backups public-url\`` | |
`pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database_name} latest.dump` | |
ensure | |
`rm latest.dump` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment