Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Visit the Heroku Blog

    Find news and updates from Heroku in the blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Troubleshooting Node.js Apps
      • Working with Node.js
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • Inference Essentials
      • AI Models
    • Vector Database
    • Model Context Protocol
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Databases & Data Management
  • Heroku Postgres
  • Postgres Data Transfer & Preservation
  • Heroku Postgres Rollback

Heroku Postgres Rollback

English — 日本語に切り替える

Last updated October 01, 2024

Table of Contents

  • Creating a Rollback Database
  • Deprovisioning
  • Rollback Status
  • Common Use Case: Recovery After a Critical Data Loss

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, it can be promoted 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
=== HEROKU_POSTGRESQL_YELLOW_URL (DATABASE_URL)
Plan:        Standard 0
Status:      Available
Data Size:   584.6 MB
Tables:      29
PG Version:  9.2.4
Connections: 8
Fork/Follow: Available
Rollback:    from 2013-10-18 20:00 UTC
Created:     2013-04-18 20:14 UTC
Maintenance: not required

There’s a delay before rollback is available on a new fork after forking and on followers after unfollowing.

Creating a rollback database uses the same mechanism as creating a follower: provisioning occurs on creation of a new database add-on with the --rollback flag. The --rollback flag can take the config var name of the database on the same app, an argument of the form appname::HEROKU_POSTGRESQL_COLOR, or the full URL of any Heroku Postgres database.

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: 2013-10-22 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 --to flag, 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:

The addons:create example follows the syntax for Heroku CLI v9.0.0 or later. If you’re on v8.11.5 or earlier, use the command:

$ heroku addons:create heroku-postgresql:standard-0 --rollback HEROKU_POSTGRESQL_YELLOW --to '2013-10-21 15:52+00' --app example-app
$ heroku addons:create heroku-postgresql:standard-0 --app example-app -- --rollback HEROKU_POSTGRESQL_YELLOW --to '2013-10-21 15:52+00'

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 HEROKU_POSTGRESQL_SILVER_URL... available

Deprovisioning

When you’re done with the rollback, deprovision it using heroku addons:destroy:

$ heroku addons:destroy HEROKU_POSTGRESQL_YELLOW --app example-app
    !    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

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:

  1. Create a rollback:

    The addons:create example follows the syntax for Heroku CLI v9.0.0 or later. If you’re on v8.11.5 or earlier, use the command:

    $ heroku addons:create heroku-postgresql:standard-0 --rollback HEROKU_POSTGRESQL_YELLOW --to '2013-10-21 15:52+00' --app example-app
    
    $ heroku addons:create heroku-postgresql:standard-0 --app example-app -- --rollback HEROKU_POSTGRESQL_YELLOW --to '2013-10-21 15:52+00'
    Creating heroku-postgresql:standard-0 on ⬢ example-app... $50/month
    Database will become available after it completes rolling back
    to 2013-10-21 15:52+0000.
    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 documentation
    
  2. Confirm that the rollback database is provisioned:

    $ heroku pg:wait --app example-app
    Waiting for database HEROKU_POSTGRESQL_SILVER... available
    
  3. Promote the rollback as the primary database:

    $ heroku pg:promote HEROKU_POSTGRESQL_SILVER --app example-app
    
  4. Recreate all followers on the new leader (if applicable):

    The addons:create example follows the syntax for Heroku CLI v9.0.0 or later. If you’re on v8.11.5 or earlier, use the command:

    $ heroku addons:create heroku-postgresql:standard-0 --follow HEROKU_POSTGRESQL_SILVER --app example-app
    
    $ heroku addons:create heroku-postgresql:standard-0 --app example-app -- --follow HEROKU_POSTGRESQL_SILVER
    Creating heroku-postgresql:standard-0 on ⬢ example-app... $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
    

Keep reading

  • Postgres Data Transfer & Preservation

Feedback

Log in to submit feedback.

SQLite on Heroku Importing and Exporting Heroku Postgres Databases

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices