Skip to content

Instantly share code, notes, and snippets.

@mattbeedle
Created November 22, 2013 16:27
Show Gist options
  • Save mattbeedle/7602678 to your computer and use it in GitHub Desktop.
Save mattbeedle/7602678 to your computer and use it in GitHub Desktop.
A simple bash script to replicate your heroku database onto your development database. Stick it in to your scripts folder in a rails app and chmod+x it. Then you can run ./script/replicate and debug any production issues with the production data.
#!/usr/bin/env bash
echo "Running: heroku pgbackups:capture --remote production"
heroku pgbackups:capture --remote production
echo "curl'ing the latest.dump"
curl -o latest.dump `heroku pgbackups:url --remote production`
echo "restoring the dump"
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d project_name_development latest.dump
echo "removing latest.dump"
rm latest.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment