Search Postgresql Archives

Re: Backing up a DB excluding certain tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx 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@xxxxxxxxxxxxx> wrote:
[ please keep the list cc'd ]

JORGE MALDONADO <jorgemal1960@xxxxxxxxx> 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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux