pg_dump: No Matching Schemas Found in PostgreSQL

case sensitivepg-dumppostgresqlpostgresql-9.4

I am trying to dump a schema from Postgres 9.4, running on Cents 6.5, but I get an error:

pg_dump: No matching schemas were found

Here is the command I am running:

pg_dump -U postgres -n "OLD-TODELETE-bushes" --verbose site > output_nf

I am a little confused by this as when I run select schema_name from information_schema.schemata, I can see the schema name.

If I run pg_dump for all schemas the OLD-TODELETE-bushes is dumped to file, as expected.

There are no error's in the Postgres logs.

Anyone have any ideas?

Best Answer

Fixed this by changing the quotes from "schema_name" to '"schema_name"'

See: pg_dump doesn't dump datascheme with uppercase letters in

...where Tom Lane replied:

The problem is that there are two levels of quoting needed: one for the shell and one for SQL. As you wrote it, the double quotes are stripped off by the shell and so pg_dump gets Schema, which is case-folded per normal SQL rules. So you need to write:

pg_dump -n '"Schema"' -U postgres database

Now, the shell eats the single quotes and passes "Schema" to pg_dump.