supabase / setup-cli

A GitHub action for interacting with your Supabase projects using the CLI.
MIT License
107 stars 15 forks source link

DB Dump - network unreachable #266

Closed EricHasegawa closed 6 months ago

EricHasegawa commented 6 months ago

Describe the bug

There's a bunch of people with the same error discussing it here, seems like its fixed in a CLI update but hasn't been updated here.

To Reproduce

Try something like ` - uses: supabase/setup-cli@v1 with: version: latest

Expected behavior

Creates backups for me

sweatybridge commented 6 months ago

With the new IPv6 rollout, db-url flag won't work on hosts that only support IPv4. You need to link the project before running db dump.

EricHasegawa commented 6 months ago

With the new IPv6 rollout, db-url flag won't work on hosts that only support IPv4. You need to link the project before running db dump.

Could you please link to docs that show how to link the project via github actions? Or point me to anywhere I can learn how to do this?

sweatybridge commented 6 months ago
env:
  SUPABASE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
  SUPABASE_DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
  # Retrieve <project-id> from dashboard url: https://app.supabase.com/project/<project-id>
  PROJECT_ID: <project-id>

 steps:
   - uses: supabase/setup-cli@v1
     with:
       version: latest
   - run: supabase link --project-ref $PROJECT_ID
   - run: supabase db dump

You can find more examples in https://github.com/supabase/supabase-action-example

EricHasegawa commented 6 months ago
env:
  SUPABASE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
  SUPABASE_DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
  # Retrieve <project-id> from dashboard url: https://app.supabase.com/project/<project-id>
  PROJECT_ID: <project-id>

 steps:
   - uses: supabase/setup-cli@v1
     with:
       version: latest
   - run: supabase link --project-ref $PROJECT_ID
   - run: supabase db dump

You can find more examples in https://github.com/supabase/supabase-action-example

thank youu <3

EricHasegawa commented 6 months ago

Reopening - came back to this today and got linking to work

supabase link --project-ref $PROJECT_ID -p $SUPABASE_DB_PASSWORD --debug

supabase db dump --db-url "$supabase_db_url" -f ${{ env.NOW }}/${{ env.NOW }}-roles.sql --role-only
supabase db dump --db-url "$supabase_db_url" -f ${{ env.NOW }}/${{ env.NOW }}-schema.sql
supabase db dump --db-url "$supabase_db_url" -f ${{ env.NOW }}/${{ env.NOW }}-data.sql --data-only --use-copy

After the link successfully works, I get the same error

pg_dumpall: error: connection to server at "db.***.supabase.co" (2600:1f1c:f9:4d01:9e81:2dee:1ab0:95ff), port 5432 failed: Network is unreachable
    Is the server running on that host and accepting TCP/IP connections?

@sweatybridge Any advice?

sweatybridge commented 6 months ago

After linking, you want to run db dump without --db-url flag. For eg.

supabase db dump -f ${{ env.NOW }}/${{ env.NOW }}-roles.sql --role-only

Otherwise CLI won't pick up the pooler url from the linked project.