Script to copy production db to staging env on heroku?

Does anybody have a good shortcut for copying a production database on heroku to a staging database on heroku?

I can do this manually by:

  1. Take backup
  2. Download backup
  3. Upload backup to AWS
  4. Restore backup

Thanks.

The parity gem does a great job of this. You can use this command:

production backup && staging restore production

to take a snapshot of your production database and bring it down to staging.

Here’s the link. You need to set your app name if you’re not using the suggested app name convention:

2 Likes