Re:Downloading Large Heroku Postgres Backups
by kylecordes on Friday November 15, 2019 @10:51AM
(#21545784)
It warms my heart to read of people doing this: development on scrubbed data.
It is sadly not unusual, even at companies with resources and knowledge to do better, to hand production data (including ample customer personal data) to every developer.
1. fork the production db and wait for it to sync
2. run a task within the production Heroku app pointing at the new fork which does the PII scrubbing and compacting[1]
3. `pg_dump` the compressed result onto the Heroku dyno running the task above
4. upload the dump as a release on the GitHub page for our main codebase
When a developer wanted a fresh dev database all they had to do was run a local rake task that would grab the db dump from the latest GitHub release, drop their local database, and restore the dump.
[1]: This isn't as easy as it sounds because one of the tables we wanted to compress contained raw financial data, but we wanted a coherent story for dev, so we dropped 95% of the data, keeping more recent stuff, randomized all the amounts, and then recalculated summary tables.