This guide shows how to migrate your Heroku Postgres database to Hydra. This migration requires the pg_dump and psql CLI tools, which are installed automatically as part of the complete PostgreSQL installation package.

Retrieve your Heroku database credentials

  1. Log in to your Heroku account and select the project you want to migrate.
  2. Click Resources in the menu and select your Heroku Postgres database.
  3. Click Settings in the menu.
  4. Click View Credentials and save the following information:
    • Host ($HEROKU_HOST)
    • Database ($HEROKU_DATABASE)
    • User ($HEROKU_USER)
    • Password ($HEROKU_PASSWORD)

Retrieve your Hydra Postgres connection string

  1. If you’re new to Hydra, create a project.
  2. Go to the project section for your project in the Hydra Dashboard.

Export your Heroku database to a file

Use pg_dump with your Heroku credentials to export your Heroku database to a file (e.g., heroku_dump.sql).

pg_dump --clean --if-exists --quote-all-identifiers -h $HEROKU_HOST -U $HEROKU_USER -d $HEROKU_DATABASE --no-owner --no-privileges > heroku_dump.sql

Import the database to your Hydra project

Use psql to import the Heroku database file to your Hydrsa project.

psql -d "$YOUR_CONNECTION_STRING" -f heroku_dump.sql

Additional options

  • To only migrate a single database schema, add the --schema=PATTERN parameter to your pg_dump command.
  • To exclude a schema: --exclude-schema=PATTERN.
  • To only migrate a single table: --table=PATTERN.
  • To exclude a table: --exclude-table=PATTERN.

Run pg_dump --help for a full list of options.

  • If you’re planning to migrate a database larger than 6 GB, we recommend upgrading to at least a Medium compute instance. This will ensure you have the necessary resources to handle the migration efficiently.
  • You can increase the size of the disk on paid projects by navigating to the project Settings tab.
  • If you’re dealing with a database larger than 150 GB, we strongly advise you to contact our support team for assistance in provisioning the required resources and ensuring a smooth migration process.

Enterprise

Contact us if you need more help migrating your project.