Re: Backing up a DB excluding certain tables

From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Backing up a DB excluding certain tables
Date: 2022-04-27 22:45:58
Message-ID: CAAY=A7-aRQ7SaEjVzpQXmtBsL+fAKE+aQmUwkgxM2D6NHDGSKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is this the correct way to answer when you say that I must *keep the list
cc'd*? I am not sure if I only have to reply to the
*pgsql-general(at)lists(dot)postgresql(dot)org
<pgsql-general(at)lists(dot)postgresql(dot)org>* list or also include individual
emails like yours and Adrian's.

I have tried many ways to make this pg_dump command work without success. I
just do not know what is going on. The last test I performed was as follows
which only excludes 1 table in the *riopoderoso* schema but it did not
work. Such a table is included in the resulting backup plain format file.

*pg_dump -E win1252 -f c:/temp/respaldo.backup -n riopoderoso -F p -h
localhost -p 5432 -U postgres -W -s -T 'riopoderoso."AspNetRoleClaims"'
riopoderoso*

If there are any additional comments please let me know. I will keep
trying. It is important to exclude these tables because they are created
and managed by other means. Such tables are part of the authentication
feature included in ASP.NET Core.

With respect,
Jorge Maldonado

On Tue, Apr 26, 2022 at 6:36 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> [ 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 David G. Johnston 2022-04-27 23:16:43 Re: Backing up a DB excluding certain tables
Previous Message Peter J. Holzer 2022-04-27 20:05:37 Re: Replication with Patroni not working after killing secondary and starting again