Migrating from Heroku is quick and easy using standard Postgres database archival and recovery tools. In this guide, we walk you through the process of:
postgreswith the bundled
- Archiving your Herkou-Postgresql database
- Restoring your database to bit.io
Postgres comes bundled with a number of tools including
pg_restore. We can use
pg_dump to archive a Heroku-Postgres database and
pg_restore to restore the database as a bit.io database. You can read more about the general usage of
Postgres installation varies by system:
brew install postgres
Debian and Ubuntu:
sudo apt install postgres
Fedora and Red Hat:
sudo dnf install postgresql
Download the official postgres installer from the official postgres docs and follow the provided prompts/instructions.
On heroku.com, navigate to the "Settings" for your Heroku-Postgres resource and copy the "URI" field (blue highlight) under database credentials.
Using the "URI" field, run
pg_dump with the following options as shown below:
--no-privileges- bit.io provides streamlined database permissions, similar to Google-docs, that supersede lower-level Postgres permissions. This option tells the utility to not export existing Postgres permissions that are not applicable on bit.io and would otherwise cause error messages when restored to bit.io. You can read more about bit.io sharing and permissions in our getting started guide.
--format custom- created a compressed archive that is compatible with
--file- specify a file name for the archive on the machine running the command.
pg_dump --no-privileges --format custom --file heroku_archive \ postgres://youruserid:[email protected]:5432/yourdatabaseid
You should now have a file containing an archive of your Heroku-Postgres database.
Next, create an account on bit.io and create a free database. From your database page, click the connect tag and copy your bit.io Postgres connection string.
pg_restore with the
--no-owner option (ownership is superseded by bit.io managed permissions and sharing, as discussed above) and your bit.io Postgres connection string to restore your database from the archive file.
pg_restore --no-owner \ -d postgresql://yourusername:[email protected]/yourdatabasename \ "heroku_archive"
From there, you can use the bit.io connect tab to get credentials for any existing applications or clients that connect to your database.
If you run into issues not covered in this guide, please reach out to us for help at [email protected]!
Updated 5 months ago