I have a script where pg_dump
is failing with a message like this:
pg_dump -h db1 --format plain --encoding UTF8 --schema=public --schema-only --no-owner me
pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation notmytable
pg_dump: [archiver (db)] query was: LOCK TABLE public.notmytable IN ACCESS SHARE MODE
This is causing the whole dump to abort.
Is there a way to either:
- Ignore tables that aren't owned by our user?
- Ignore errors?
I really don't want these tables in the dump, so even if we could get access to them, that wouldn't exactly solve the problem.
(Postgres 9.6.3)
It doesn't appear there is a standard way to do this, but using the
--exclude-table
flag, we can use a workaround:This sets EXCLUDETABLE to look like
--exclude-table=foo --exclude-table=blah
Now we pass that to
pg_dump
: