Here are the steps to download and setup the database locally:
- Make sure you are in project directory
- Get the latest database backup url from heroku using below command:
heroku pg:backups public-url
- Copy the url and paste it into the browser and hit Enter. This will download the file (which is encrypted).
- Rename the downloaded file to something more appropriate (Ex: latest.dump). Note the extension being “.dump”.
- Create a new postgres database (Ex: latest_database) sorry for the weird name, I just couldn’t think of anything better. LOL
- Run this command to restore
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U your_username -d your_database_name path/to/latest.dump
P.S. You can check the status of backups at any point of time by running this command:
I hope you like this post. Please comment down below you have doubts/questions or request for any topics. Thanks for reading!