Skip to content

Instantly share code, notes, and snippets.

@dennis-best
Created July 30, 2016 14:05
Show Gist options
  • Save dennis-best/55975396515d6ee32f0fc3eea8160f72 to your computer and use it in GitHub Desktop.
Save dennis-best/55975396515d6ee32f0fc3eea8160f72 to your computer and use it in GitHub Desktop.
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