Table of Contents [expand]
Last updated January 13, 2026
Heroku Postgres rollback “rolls back” the state of your database to a previous point.
Rollback doesn’t affect your primary database. It follows the same pattern as fork: rollback provisions a new database that isn’t directly connected to the primary in any way. Like a fork, a rollback takes some time to become available. When the rollback is available, you can promote it to primary. When the rollback is primary, you can remove the previous add-on.
The rollback period varies by database plan.
If database credentials have been reset on the primary, rollback continues to support going back to a point before credential reset. After the fork is created during the rollback process, a new set of credentials is created.
Creating a Rollback Database
Before you roll back, ensure the desired rollback point is available for your database. Different database plans have different rollback availability. To check rollback availability for your current database, use the heroku pg:info command:
$ heroku pg:info --app example-app
=== DATABASE_URL, HEROKU_POSTGRESQL_YELLOW_URL
Plan: Standard 0
Status: Available
Data Size: 37.1 GB / 64 GB (58.04%)
Tables: 51
PG Version: 17.5
Connections: 31/400
Connection Pooling: Available
Credentials: 6
Fork/Follow: Available
Rollback: earliest from 2025-12-19 13:59 UTC
...
There’s a delay before rollback is available on a new fork after forking and on followers after unfollowing.
You can create a rollback database using the Heroku CLI with the heroku addons:create command. Provision a new database add-on with the --rollback flag. Supply the flag with one of the following identifiers to specify the database you want to roll back:
- The config var name of the database on the same app
- The name of the database add-on
- The full URL of any Heroku Postgres database
- An argument in the form of
appname::HEROKU_POSTGRESQL_COLOR_URL. This argument allows you to create a fork of a database that’s attached to another app.
You can provide an alias for the new fork database with the --as option when running heroku addons:create. Heroku uses the provided alias as the attachment name for the new database and its related add-on config vars.
In addition, you must specify the time to roll back to. There are two ways to indicate the desired time:
Explicit Timestamp: You can specify an explicit timestamp. Use the format
2013-10-22 12:34+00:00. You must include the time zone offset. You can also use a symbolic time zone:2025-08-04 12:34 US/Pacific.Interval: You can specify an interval. Use the format
3 days 7 hours 22 minutes. A recovery time must be passed with the--toflag, and a recovery interval with--by. At least one must be present, but not both. Rollback isn’t accurate down to the second. Seconds specified in the recovery time or interval are ignored.
The following example shows a full rollback:
$ heroku addons:create heroku-postgresql:standard-0 --as ROLLBACK_20250804 --app example-app -- --rollback HEROKU_POSTGRESQL_YELLOW --to '2025-08-04 15:52:00+00'
Creating heroku-postgresql:standard-0 on ⬢ example-app... ~$0.069/hour (max $50/month)
Database will become available after it completes rolling back
to 2025-08-04 15:52:00 +0000 (1 day 14:03:22 ago).
Use `heroku pg:wait` to track status.
postgresql-dimensional-12345 is being created in the background. The app will restart when complete...
Use heroku addons:info postgresql-dimensional-12345 to check creation progress
Use heroku addons:docs heroku-postgresql to view documentation
Use single quotes ' around the timestamp for Unix-like operating systems and double quotes " around the timestamp for Windows.
The command echoes the target recovery time (and elapsed time) to the command line.
Preparing a rollback can take anywhere from several minutes to several hours, depending on the size of your dataset. The heroku pg:wait command shows the provisioning status of any new databases and can be used to determine when the rollback is up to date:
$ heroku pg:wait --app example-app
Waiting for database postgresql-dimensional-12345... available
Deprovisioning
When you’re done with the rollback, deprovision it using heroku addons:destroy:
$ heroku addons:destroy HEROKU_POSTGRESQL_SILVER --app example-app
› Warning: WARNING: Destructive Action
› This command will affect the app example-app
To proceed, type example-app or re-run this command with --confirm example-app: example-app
Destroying postgresql-dimensional-12345 on ⬢ example-app... done
Rollback Status
You can check the status of rollback for your database by running heroku pg:info. There are three potential statuses for the Rollback field.
Rollback: from YYYY-MM-DD HH:SS UTC: Your database supports rollback and has an available backup. It shows the timestamp of the earliest rollback point.Rollback: Capturing Snapshot: Your database supports rollback and the first backup is in progress.Unsupported: Your database doesn’t support rollback.
Common Use Case: Recovery After a Critical Data Loss
Rollback is a great safety net for critical data loss issues like accidentally dropping an important table. To recover the lost data through rollback:
Create a rollback:
$ heroku addons:create heroku-postgresql:standard-0 --app example-app -- --rollback HEROKU_POSTGRESQL_YELLOW --to '2025-10-21 15:52+00' Creating heroku-postgresql:standard-0 on ⬢ example-app... ~$0.069/hour (max $50/month) Database will become available after it completes rolling back to 2025-10-21 15:52+0000 (1 day 14:03:22 ago). Use `heroku pg:wait` to track status. postgresql-adjacent-88888 is being created in the background. The app will restart when complete... Use heroku addons:info postgresql-adjacent-88888 to check creation progress Use heroku addons:docs heroku-postgresql to view documentationConfirm that the rollback database is provisioned:
$ heroku pg:wait --app example-app Waiting for database postgresql-adjacent-88888... availablePromote the rollback as the primary database:
$ heroku pg:promote postgresql-adjacent-88888 --app example-appRecreate all followers on the new leader (if applicable):
$ heroku addons:create heroku-postgresql:standard-0 --app example-app -- --follow HEROKU_POSTGRESQL_SILVER Creating heroku-postgresql:standard-0 on ⬢ example-app... ~$0.069/hour (max $50/month) The database should be available in 3-5 minutes. Use `heroku pg:wait` to track status. postgresql-rigid-99330 is being created in the background. The app will restart when complete... Use heroku addons:info postgresql-rigid-99330 to check creation progress Use heroku addons:docs heroku-postgresql to view documentation