question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permission error when backing up the database with `pg_dump`

See original GitHub issue

Bug report

Describe the bug

I have a project that I need to make a local backup of, I have database triggers and functions.

When I tried this command pg_dump 'postgresql://postgres:password@db.id.supabase.co:5432/postgres' > backup.sql It gave me this error:

pg_dump: error: query failed: ERROR:  permission denied for table hooks
pg_dump: error: query was: LOCK TABLE supabase_functions.hooks IN ACCESS SHARE MODE

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a database function with trigger type
  2. Create a database trigger that fires that function
  3. Try pg_dump
  4. See error

Expected behavior

Backup to be completed

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Linux
  • Browser Firefox
  • Version of supabase-js: 2.2.0
  • Version of Node.js: v19.2.0

Additional context

I did NOT mess with permissions, I also tried DBeaver and faced the same issue

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Geczycommented, Dec 24, 2022

awesome, then i changed my dump to

pg_dump -d "${DATABASE_URL%\?*}" \
    --no-comments \
    -F c \
    -N supabase_functions \
    -f "$backup_file"

i also gzip this file after

gzip -f "$backup_file"

full script here

1reaction
amr3kcommented, Dec 24, 2022

This comment solved it for me:

#1856 (comment)

Adding -N supabase_functions

➜  ~ pg_dump -d "postgresql://postgres:<pass>@db.<projectid>.supabase.co:5432/postgres" --no-comments -N supabase_functions -N auth -N realtime > out.sql

Thanks @Geczy , but for a better approach, I used these extra options -F c -v -f db.dump to be able to restore it with pg_restore

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgresql dump permission denied
I wrestled with this "Permission Denied" issue while trying to backup my PSQL database on an Ubuntu machine for a long time, and...
Read more >
"Permission denied" error when using pg_dump to backup ...
Hello, I m trying to make backup. i have master password and i double confirm ... in "Manage Databases". it shows popup message...
Read more >
pg_dump permission denied for sequence
My guess that this is simply a permission issue towards the object that is attempted to be dumped. Excluding the sequence would work...
Read more >
pg_dump fails with 'permission denied for table audits' - GitLab
When trying to backup our GitLab CE 13.7.3 instance (Omnibus, docker container), the process fails. We have successfully executed (many) backups ...
Read more >
Permission denied for sequence jobid_seq when trying to ...
I am trying to perform a backup of my database in Azure Database for ... pg_dump: error: query failed: ERROR: permission denied for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found