Issue
I need to recover a deleted production-tier Heroku Postgres database
Resolution
You're able to recover a production-tier database for up to 10 days after it has been deprovisioned.
To do so:
- Identify the release during which the database status is marked as
DETACH
. Use the version of the release prior to this in step 2. - Get the old database URL for the resource by running
heroku releases:info <releaseversion> --app <APP_NAME>
. This URL will be used in step 3. - Create a new database with
heroku addons:create heroku-postgresql:<plan> --app <APP_NAME> --fork <old-database-url>
. - Wait for the database to become available with
heroku pg:wait --app <APP_NAME>
.
If this doesn't work for some reason, you may be able to restore a PGBackup even if the database was recently deleted. If the app is not deleted, you can check if there is any backups that can be used for the recovery (heroku pg:backups -a <APP_NAME>
).