Skip to content

Instantly share code, notes, and snippets.

@rands0n
Created April 5, 2016 12:29
Show Gist options
  • Save rands0n/5f1c02920687c05c6a4a6153b6cdab1c to your computer and use it in GitHub Desktop.
Save rands0n/5f1c02920687c05c6a4a6153b6cdab1c to your computer and use it in GitHub Desktop.
namespace :db do
desc "Copy production database to local"
task :copy_production => :environment do
# Download latest dump
system("wget -O tmp/latest.dump `heroku pg:backups public-url -q`")
# get user and database name
config = Rails.configuration.database_configuration["development"]
database = config["database"]
user = config["username"]
# import
system("pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database} #{Rails.root}/tmp/latest.dump")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment