Heroku to fly postgres migration guide not working

I am following the steps here: Migrate from Heroku · Fly Docs

this works:
fly secrets set HEROKU_DATABASE_URL=$(heroku config:get DATABASE_URL)

this fails:
pg_dump --no-owner -C -d $HEROKU_DATABASE_URL | psql -d $DATABASE_URL

The problem is the env variable DATABASE_URL is not set. It exists as a fly secret, but not as an env. What can I do about that?

Since it is still in beta it is highly likely that the fly docs you’re following might be missing something, what error message do you see when you run the pg_dump --no-owner -C -d $HEROKU_DATABASE_URL | psql -d $DATABASE_URL command ?

Try sshing into your app using fly ssh console and then run the pg_dump command

The error is /usr/lib/postgresql/14/bin/psql: option requires an argument -- 'd'. Then if you do echo $DATABASE_URL the variable is empty. Which is apparently expected, so yeah, the trick seems to be to ssh. Unfortunately,

fly ssh console fails for me with: Error host unavailable: host was not found in DNS

There are issues for that in the forum, but no solution worked so far.

For the fly ssh console failure can you see if you can ssh using the specific vm ip address

  1. List the private ip address
 fly ips private
  1. Ssh into the listed vm address
fly ssh console -s <ipv6-address>

And if the pg_dump command still fails after you ssh, then getting your database downloaded locally and then uploading it to postgres has been some users workaround.

You might find this post of a customer with a similar issue helpful

Thank you. Yeah, sadly fly ips private only returns an empty list. In the dashboard it shows the builder running, so at least that should you up in that list. So there is no machines I could ssh into. I also tried the basic docke example (Run a Global Image Service · Fly Docs), which fails with

Error failed to fetch an image or build from source: error building: failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 1.1.1]: 500 Internal Server Error

I am currently encountering the same issue (failed to solve with frontend dockerfile.v0). Seems like it doesn’t happen for all Docker images (for instance I would pull a node image just fine, but pulling a swift image didn’t work and had the exact same error)

Do you have any Dockerfile that works? My app will be based on a dockerfile I create, so if I could start with something that works it would maybe give me a running instance to which I then can ssh…

The Dockerfile I was using should work fine yes. I believe it’s the image pull that fails unfortunately

Yeah, the image pull fails in many cases. ubuntu:latest works. Could you share that Dockerfile with me? I couldn’t find a dockerfile that works.

The Dockerfile I’m using on a project where the pull worked is this one: Mannele/Dockerfile at main · PopFlamingo/Mannele · GitHub

It pulls node:18.

Pulling swift:5.6-focal always fails in my case today. Used to worked other days of course.

I wonder if it has anything to do with node:18 and ubuntu:latest being more popular than other images and maybe being cached somewhere else that’s currently available to the fly builder contrary to other servers.

Thank you! I also just managed to come up with a minimal Dockerfile that works:

FROM python:latest
EXPOSE 8080
CMD python -m http.server 8080
1 Like

Okay, I got the db migration done finally. Steps:

  1. use minimal Dockerfile above to get a pod running
  2. ssh into the pod
  3. run the pg_dump command. I ran into issues with roles don’t exist, echo "CREATE ROLE misingrole" | psql -d $DATABASE_URL did the trick, then run the pg_dump command again and hope it’s idempotent.