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

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Working with Django
      • Background Jobs in Python
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Java Advanced Topics
      • Working with Spring Boot
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • 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 Basics
  • Forking Your Heroku Postgres Database

Forking Your Heroku Postgres Database

English — 日本語に切り替える

Last updated September 16, 2021

Table of Contents

  • Use Cases
  • Create a Fork
  • Fork Fast Option
  • Delete a Fork

Forking creates a new database containing a snapshot of an existing database at the current point in time. Unlike follower databases, forks don’t stay up to date with the parent database and you can write to them. Forks don’t affect the performance of the parent database.

Forking is only supported on production tier database plans. Follow these steps to upgrade from a hobby tier (dev or basic) plan to a production plan.

Use Cases

Forks don’t affect the performance of the parent database.

Forked databases provide a risk-free way of working with your production data and schema. For example, you can use them to test new schema migrations or to load test your application on a different database plan. They’re also valuable as snapshots of your data at a particular point in time for later analysis or forensics.

Create a Fork

You can create forks on any Standard, Premium, Private, or Shield database that isn’t a follower.

You can’t create forks from another newly forked database for a short period of time. This limitation applies both to forks created by the methods described in this article and to forks created through unfollow. Use the pg:info command to check if Fork/Follow is Available.

Forks don’t have to be on the same database plan as the parent database. Forks can be on any plan but must have enough disk space to contain the data from the parent database.

Preparing a fork can take anywhere from several minutes to several hours, depending on the size of your dataset.

After forking a database, the app the fork is attached to updates with a new HEROKU_POSTGRESQL_COLOR_URL config var. This config var update restarts the app.

Create Using the CLI

You can create forks using the Heroku CLI with the heroku addons:create command. Provision a new database add-on with the --fork flag. Supply the flag with one of the following:

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, or an argument in the form of appname::HEROKU_POSTGRESQL_COLOR_URL. This allows you to create a fork of a database that is attached to another app.

$ heroku addons:create heroku-postgresql:standard-0 --fork HEROKU_POSTGRESQL_CHARCOAL_URL --app example-app
Adding heroku-postgresql:standard-0 on example-app... done, v71 ($50/mo)
Attached as HEROKU_POSTGRESQL_SILVER_URL
Database will become available after it completes forking
Use `heroku pg:wait` to track status

The heroku pg:wait command outputs the provisioning status of any new databases. Use it to determine when the fork is up to date.

$ heroku pg:wait --app example-app
Waiting for database HEROKU_POSTGRESQL_SILVER_URL... available

Create Using the Heroku Data Dashboard

You can also create forks through the web dashboard:

  1. Go to data.heroku.com.
  2. Use the search and select the database you want to create a fork from.
  3. Click the Settings tab.
  4. Click Fork Database....
  5. Choose the plan for the fork. Review the Create a Fork section for notes on selecting a plan size.
  6. Click Fork Database.

The dashboard shows the status of the forked database and updates when the provisioning is complete.

Fork Fast Option

Fast forks can be up to 30 hours out-of-date.

You can create forks faster via the CLI with the --fast flag. This option is useful if no major changes, such as schema migrations or large data imports, occurred in your database in the last 30 hours.

$ heroku addons:create heroku-postgresql:standard-4 --fork HEROKU_POSTGRESQL_CHARCOAL --fast --app example-app

Adding heroku-postgresql:standard-4 on dashboard... done, v1022 ($1200/mo)
Attached as HEROKU_POSTGRESQL_BLUE_URL

Fork will contain data from 5/26/2021 at 13:56 UTC (about 16 hours old)
To create a fork with up-to-date data, exclude the `--fast` flag.

Database will become available after it completes forking
Use `heroku pg:wait` to track status.
Use `heroku addons:docs heroku-postgresql` to view documentation

Delete a Fork

Delete Using the CLI

Deprovision a fork using heroku addons:destroy:

Be sure to remove the _URL suffix from the database name in this command.

$ heroku addons:destroy HEROKU_POSTGRESQL_SILVER --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

Delete Using the Heroku Data Dashboard

  1. Go to data.heroku.com.
  2. Use the search and select the database you want to create a fork from.
  3. Click the Settings tab.
  4. Click Delete Database....
  5. Type in the name of your app to confirm.
  6. Click Delete Database.

Keep reading

  • Postgres Basics

Feedback

Log in to submit feedback.

Upgrading the Version of a Heroku Postgres Database Heroku PGSettings

Information & Support

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

Language Reference

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

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences