Re: Backing up a DB excluding certain tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Backing up a DB excluding certain tables
Date: 2022-04-26 23:36:06
Message-ID: 282742.1651016166@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[ please keep the list cc'd ]

JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> writes:
> As for the answer by *Tom Lane*, I am not restoring the DB but only getting
> the backup in plain format. I see that tables that contain "AspNet" in
> their name are part of the resulting dumped file. For example, the
> following is part of the resulting backup plain file:

> CREATE TABLE riopoderoso."AspNetRoleClaims" (
> "Id" integer NOT NULL,
> "RoleId" character varying(450) NOT NULL,
> "ClaimType" text,
> "ClaimValue" text
> );

Ah. Now that you actually showed us what you're doing, there are
two problems:

1. "aspnet*.*" is trying to match a *schema* name starting with "aspnet",
not a *table* name. What you want is more like "*.aspnet*", or possibly
"riopoderoso.aspnet*". (You can't just write "aspnet*", because
riopoderoso isn't going to be in pg_dump's search path, and that pattern
would only match tables in the search path.)

2. You're not accounting for case. Per the discussion of patterns
in the psql reference manual, to match an upper-case name you'd need
to spell it with the correct casing and then put double quotes around
it.

Actually there's a third problem, which is to get the shell to not strip
the double quotes from the pattern before handing it to pg_dump.

For me, a dump command like

pg_dump -n riopoderoso -T '*."AspNet"*' ...

does what you want. However, I gather you're doing this on Windows,
and I'm not sure whether shell command quoting rules are the same there.
You might need something weird like backslashing the double quotes.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Kidman 2022-04-27 00:05:30 errcodes.h and others not generated when compiling 13.6 on M1 Mac
Previous Message Adrian Klaver 2022-04-26 22:10:47 Re: Fresh eyeballs needed: input into error