A backup of your database is useless unless you are able to quickly and reliably restore from it. This process is something that you won't use often, but it's critical that you know how to do it and have practiced using it. If you ever need to do an emergency restore, you want to be confident that you can and know how to do it. In this recipe, you will be learning how to recreate your database on Heroku from a Postgres dump.
You'll need to have the pgbackups
add-on installed and a backup of your database created. For instructions on how to do this, refer to the previous recipe, Creating a database backup.
To start, let's open up a terminal. We'll be using the Heroku CLI to restore our backup:
To restore our primary database from our most recent backup, we can run the
pgbackups:restore
command without any arguments:$ heroku pgbackups:restore
It will take the most recently created backup and restore it to the database set in our
DATABASE_URL
...