The easiest way to recover your data is to keep frequent backups. Heroku provides a very convenient mechanism to back up your data through the free pgbackups
add-on. Use this add-on to create data backups on demand.
To create a backup, you need to first add the pgbackups
add-on to your account. To do so, use the following command:
$ heroku addons:add pgbackups Adding pgbackups to test-db-app... done, v... (free) You can now use "pgbackups" to backup your databases or import an external backup. pgbackups documentation available at: https://devcenter.heroku.com/articles/pgbackups
There are multiple options available in the form of backup plans that you could use based on your business needs. Your decision to use a particular plan may depend on the level of automation needed, number of exports required, and the retention period of the backup. By default, the automated backup is performed on the database pointed to by the DATABASE_URL
configuration parameter...