Skip to content

Instantly share code, notes, and snippets.

@jontonsoup
Created November 17, 2014 19:39
Show Gist options
  • Save jontonsoup/bc4cb003c6b3402592aa to your computer and use it in GitHub Desktop.
Save jontonsoup/bc4cb003c6b3402592aa to your computer and use it in GitHub Desktop.
backup script
namespace :mirror do
desc "Mirror production database"
task :production do
app = "skilledup-academy-staging"
production_database = "skilledup-academy-production::DATABASE_URL"
heroku_command("pg:reset DATABASE_URL", app)
transfer_database("#{production_database} DATABASE_URL", app)
heroku_command("run rake db:migrate", app)
end
def transfer_database(command, app)
heroku_command("pgbackups:transfer #{command}", app)
end
def heroku_command(command, app)
`heroku #{command} -a #{app} --confirm #{app}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment