From: Ron <ronljohnsonjr@gmail.com>
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: How to fully restore a single table from a custom dump?
Date: Tue, 9 Aug 2022 12:18:24 -0500
Message-ID: <3ff41470-0eb2-0f29-86c3-86c37dd15f20@gmail.com> (raw)
In-Reply-To: <CAECtzeXyzFE_D6sU3w0h8OCjFhQRcvaAFHQKM=jZk59hc4w5ug@mail.gmail.com>
References: <e434fe3f-0159-2223-8670-411d5c21c5bd@gmx.net>
<1622540476.1110533.1660049347030@email.ionos.com>
<9ca2d8ca-a175-630e-e449-48c2dee5e0f6@jakobs.com>
<93797605-23dc-de94-d49e-0849475ad426@gmail.com>
<CAECtzeXyzFE_D6sU3w0h8OCjFhQRcvaAFHQKM=jZk59hc4w5ug@mail.gmail.com>
On 8/9/22 12:13, Guillaume Lelarge wrote:
> Le mar. 9 août 2022, 18:41, Ron <ronljohnsonjr@gmail.com> a écrit :
>
> On 8/9/22 08:21, Holger Jakobs wrote:
>> Am 09.08.22 um 14:49 schrieb MichaelDBA Vitale:
>>> Hi,
>>> If you use the directory dump method, -Fd, then you could generate
>>> an editable listing where you can selectively remove stuff that you
>>> don't want to restore, just keeping the stuff related to your
>>> specific table. You run pg_restore once to generate the listing.
>>> Then run pg_restore again using that modified listing to load into
>>> the target database. See the pg_restore docs for exact syntax.
>>> Regards,
>>> Michael Vitale
>>>> On 08/09/2022 8:06 AM EDT Thomas Kellerer <shammat@gmx.net> wrote:
>>>> Hello,
>>>> I just realized that using
>>>> pg_restore -t some_table ... some_dump_file
>>>> doesn't restore things like identity attributes
>>>> or indexes on the specified table.
>>>> The dump contains much more than just that table, so simply
>>>> using pg_restore without -t is not an option.
>>>> While I could extract the indexes manually using some clever regex
>>>> on the index names, I don't see a way to make sure that identity
>>>> definitions (or sequence values) are restored properly for the
>>>> selected table.
>>>> Any ideas, how I can _fully_ restore a single table from a custom
>>>> dump?
>>>> Thomas
>>
>> Creating a list of contained items and restoring some of them works
>> the same with custom dumps. Directory dumps have no advantage here.
>>
>> Just comment out all items you don't want to restore by putting a ;
>> in front of the lines or delete the unwanted lines altogether and
>> restore.
>>
>
> Which is less than convenient when there's 4000 tables, and each one
> has 3 or four indices, a Primary Key and one or more Foreign Keys.
>
>
> Agreed, but it's already less convenient to give 4000 -t's :-)
What's your point?
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: How to fully restore a single table from a custom dump?
In-Reply-To: <3ff41470-0eb2-0f29-86c3-86c37dd15f20@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox