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.

Unable to run `pg_dump` when following migrating between projects documentation

See original GitHub issue

Improve documentation

Link

https://supabase.io/docs/guides/database#migrating-between-projects

Describe the problem

I’m trying to add restoration support for Supabase in https://snaplet.dev, but whilst trying to dump the database I get the following error:

$ pg_dump -h db.PROJECT_REF.supabase.co -U postgres --clean --schema-only M> supabase_schema.sql

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

I can exclude the storage schema, but it would be nice to have a completely functioning restoration.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
princefishthrowercommented, Jul 25, 2022

@relferreira - but then once the dump is finished, it’s very important to then switch back:

ALTER ROLE postgres NOSUPERUSER

@TomasHubelbauer adding -N auth -N realtime didn’t solve the original issue that @peterp reported for me, i.e.:

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

In this case I also had to add -N supabase_functions (though probably not ideal for when you want to fully inspect a dump) I raised another issue here that is related: https://github.com/supabase/supabase/issues/7865 it’s unclear to me why SUPERUSER is needed at all, I don’t remember that being a part of the dump workflow when I’ve worked with Postgres previously…

4reactions
TomasHubelbauercommented, Jan 5, 2022

For anyone who’s looking to just dump/backup all their Supabase database data to have a local backup and do not care about the auth and realtime schema contents:

pg_dump -d postgresql://postgres@db.{project}.supabase.co:5432/postgres -N auth -N realtime > dump.sql

You’ll be asked for the password you set during the setup of your Supabase project. If you don’t have pg_dump, do not want to install full Postgres locally and are a macOS user, look into https://postgresapp.com/ (https://github.com/PostgresApp/PostgresApp) - you can skip the database initialization step and just add the CLI tools to your command line.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: pg_dump - PostgreSQL
Description. pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently....
Read more >
pg_dump and pg_restore - Database Migration Guide
It produces a set of SQL statements that you can run to reproduce the original database object definitions and table data. The pg_dump...
Read more >
Migrate to Aiven for PostgreSQL® with pg_dump and pg_restore
This type of error is often related to the lack of superuser-level privileges blocking non-essential queries. A typical example is due to failing...
Read more >
Bamboo fails to start after PostgreSQL migration with error ...
Migrate PostgreSQL server through pg_dump to another server; Configure bamboo.cfg.xml to refer to the new PostgreSQL server. The following ...
Read more >
PostgreSQL Migration with Database Migration Service
Start the data migration after you complete and successfully test your ... instance restart that you can't avoid, the document indicates it.
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