Skip to content

Heroku

How to back up Heroku managed PostgreSQL databases via SimpleBackups.

Heroku Postgres is a managed PostgreSQL service available as an add-on to Heroku applications. Connecting it to SimpleBackups lets you store independent backup copies in your own storage with customizable retention schedules. This guide walks you through copying your connection URI and setting up the backup.

Connecting your database

Step 1: Copy your connection string

  1. Log in to your Heroku console.
  2. Navigate to the Datastores list.
  3. Click on the database you want to back up.

Heroku data stores list showing available databases

  1. Click the Settings tab, then click View Credentials.

Heroku database settings tab with View Credentials button

  1. Copy the URI.

Heroku database credentials screen showing the URI field

Step 2: Create a database backup in SimpleBackups

  1. Navigate to Backups and click Create Backup, then select Database Backup.

SimpleBackups create backup screen

  1. Choose Serverless as the backup server type.
  2. Select PostgreSQL as the database type.
  3. Click Paste connection string and fill in the complete connection string for your Heroku Postgres database, making sure the password is included.

SimpleBackups database connection form with PostgreSQL connection string

  1. Click Validate Connection.
  2. Set a schedule and configure retention policies and storage.

SimpleBackups backup schedule configuration screen

  1. Review your configuration and save. SimpleBackups will start backing up your database according to your schedule.

Restoring a backup

To restore a backup, navigate to your backup page and open the Logs tab. Click the detail icon on the backup you want to restore from, then open the Restore tab. Generate a download link and copy it.

Heroku backup logs tab

Heroku backup detail view

Heroku restore tab with download link

Run the following command to download and decompress your backup (replace the URL with your signed download link):

bash
wget -O - "<signed-download-url>" | gunzip -c > backup.pgsql

Then restore using pg_restore, replacing <your-database-uri> with your full database connection string:

bash
pg_restore -d "<your-database-uri>" ./backup.pgsql