Trent Gm
Trent Gm

Reputation: 2487

pg_dump - no matching schemas were found - postgresql

I'm trying to use pg_dump to dump a database, but am finding that I need to specify the schema. I want to avoid this as there are implications when the schema is specified (as documented in https://www.postgresql.org/docs/current/app-pgdump.html), specifically this warning:

When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.

The command I am using: pg_dump -v -f sds.bak -Fc -n 6 --quote-all-identifiers -h dbserver.host.com -p 5432 -U postgres -d "database-name"

Output:

pg_dump: last built-in OID is 16383
pg_dump: error: no matching schemas were found

Specifying 'schema' succeeds: pg_dump -v -f sds.bak -Fc -n 6 --quote-all-identifiers -h dbserver.host.com -p 5432 -U postgres -d "database-name" --schema public

Information on the database and postgres versions:

\d:

          Name           |  Owner   | Encoding |   Collate   |    Ctype    |          Access privileges
-------------------------+----------+----------+-------------+-------------+--------------------------------------
 database-name           | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres                        +
                         |          |          |             |             | postgres=CTc/postgres               +
                         |          |          |             |             | "database-name"=CTc/postgres

\dn

postgres=> \dn
  List of schemas
  Name  |  Owner   
--------+----------
 public | postgres
(1 row)

pg_dump (PostgreSQL) 14.3

postgres version:

postgres=> select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 14.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit
(1 row)

Upvotes: 0

Views: 492

Answers (1)

Trent Gm
Trent Gm

Reputation: 2487

@JohnH spotted the issue:

The specified options include -n 6. Because of this, pg_dump is looking for a schema named 6, which I presume doesn't exist. That is the source of the error message. –

The intent was to use -j 6.

Upvotes: 0

Related Questions