Heroku PostgreSQL

How to backup Managed Heroku PostgreSQL databases via SimpleBackups

Follow these steps to create backups for a Heroku-managed PostgreSQL database using SimpleBackups. The process is designed to be straightforward, ensuring that your Heroku PostgreSQL database is securely backed up.

How to backup your Heroku database

Prerequisites

  • A SimpleBackups account.
  • Access to your Heroku Postgres service database
  • Network access from SimpleBackups to your Heroku PostgreSQL database.

Step 1: Create a Backup User in Heroku

  1. Log in to your Heroku console.
  1. Navigate to the Datastores list
  1. Click on The database you wish to backup
    1. Notion image
  1. Click on the Settings tab and then on View Credentials…
    1. Notion image
  1. Copy the URI
    1. Notion image

Step 2: Create a New Database Backup on SimpleBackups

  1. Navigate to the "Backups" section and click on "Create Backup."
  1. Select "Database Backup."
    1. Notion image
  1. You may use your own server to dump the backups, but we recommend the “serverless” option.

Step 3: Configure Database Backup Settings

  1. Choose PostgreSQL as the database type.
  1. Click “Paste connection string instead”
  1. Fill in the complete connection string for your Heroku Postgres database (make sure the password is added as well and not the asterisks *****)
    1. Notion image
  1. Click “Validate Connection”

Step 4: Schedule and Customize Your Backup

  1. Set a schedule for your backups according to your needs (e.g., daily, weekly).
  1. Customize your backup settings, such as retention policies and storage.
Notion image

Step 5: Save and Activate the Backup

  1. Review your backup configuration to ensure all details are correct.
  1. Save your backup configuration. SimpleBackups will automatically start the backup process according to your schedule.

By following these steps, you can ensure that your Heroku-managed PostgreSQL database is securely backed up, protecting your data against accidental loss or corruption.

 

Restoring backups

In order to restore your backup, Go to your backup page, then navigate into logs.

Notion image

Click on the “i” button on the backup that’s on the point of time you’d like to restore to.

Notion image

Click on the Restore tab, then generate a new download link, and copy it.

Notion image

Run the following command

wget -O - "PasteTheSignedDownloadLinkHereBetweenTheQuotes" | gunzip -c > decrypted-backup.pgsql

Then, run the pg_restore command to restore your database like so:

pg_restore -d "your_db_uri" ./decrypted-backup.pgsql
💡
Make sure that you have pg_restore updated to the latest version to avoid facing restore issues.
Did this answer your question?
😞
😐
🤩

Last updated on May 6, 2024