Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

How to Import/Export a Database from One Heroku App to Another Heroku App


Heroku is awesome! Let's say we want to copy a production database to a staging database.

We can use the pg:backups:restore command to accomplish this. Here is an example. For the source database we are using the production-app-name and for staging we are using staging-app-name. Replace these with the names of your apps.

heroku pg:backups:restore production-app-name::b001 DATABASE_URL --app staging-app-name

Where b001 is the database capture you want to restore. To make a capture run

heroku pg:backups:capture -a production-app-name

Heroku will make you retype the name of the app you want to import into because it is a destructive action.

Short and sweet.

See Heroku's docs for more information

Tagged w/ #heroku #database #postgres #commands #pg #production #staging #devops