Transferring Postgres from Heroku

Wuhu :tada: it finally worked for me.

Thank you so much @tj1 for leading me on the way. Here is a precise breakdown of what I did for it to work, with a lot of repetition from @tj1 's advice:

  1. Get your latest dump by running
heroku login
heroku pg:backups:capture
heroku pg:backups:download
  1. In one terminal, launch:
fly proxy 15432:5432 -a my-db-app-name
# make sure it's the name of your db-app, not your main app
  1. In another terminal, list your db names to get the exact name of your DB with \l:
psql -U postgres -h localhost -p 15432
postgres=> \l

   Name    |   Owner    | Encoding |  Collate   |   Ctype    |     Access privileges
-----------+------------+----------+------------+------------+---------------------------
 foobar  | flypgadmin | UTF8     | en_US.utf8 | en_US.utf8 |
 postgres  | flypgadmin | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | flypgadmin | UTF8     | en_US.utf8 | en_US.utf8 | =c/flypgadmin            +
           |            |          |            |            | flypgadmin=CTc/flypgadmin
 template1 | flypgadmin | UTF8     | en_US.utf8 | en_US.utf8 | =c/flypgadmin            +
           |            |          |            |            | flypgadmin=CTc/flypgadmin
(4 rows)
  1. Once you have your name, here foobar, import your dump with pg_restore:
pg_restore -U postgres -h localhost -p 15432 -d foobar < latest.dump

And voilà, or at least it worked for me.

6 Likes