Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLSsC-0002XR-Iz for pgsql-admin@arkaria.postgresql.org; Tue, 09 Aug 2022 17:18:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLSsA-0006tD-UL for pgsql-admin@arkaria.postgresql.org; Tue, 09 Aug 2022 17:18:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLSsA-0006oK-FV for pgsql-admin@lists.postgresql.org; Tue, 09 Aug 2022 17:18:30 +0000 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oLSs7-0004Wo-W8 for pgsql-admin@lists.postgresql.org; Tue, 09 Aug 2022 17:18:29 +0000 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-10ea30a098bso14721569fac.8 for ; Tue, 09 Aug 2022 10:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc; bh=CyUAXHMMEskRdTNBH9evoaKAXajtOB4c18DyofEoWDU=; b=m5LTZygINfmPJlZZQebo7iWjMR2jxNlQrHHv9qxw3R+bDHN3Dq0kxqMrwLPkSU6oN+ ESiGwYhDERzDOSkqU82IRTMmZppyLj/ZnqJ6QlHjAgMipHy6wGOKjh1rMArsEFY0xP1c tg1BAMdOX3wGJ5qqQwjsnuq7ZgEBTCbORrxuSOfi92IdvwXts3tSNvIR0ezVckJ2ehy8 /jPPdzaG7koN2RT1vnVRD9uM0ntQiqf2OrOfsl7V6TNnOI+6bBiUNVYn+fyffeuHNrY0 iqfMkMBrfjWDXV8lrJBsPTyP+Fm/u6uFrtBHaJvCLio2c6orV9s+Hb2yCT575mm92aDz ebiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc; bh=CyUAXHMMEskRdTNBH9evoaKAXajtOB4c18DyofEoWDU=; b=2glPkl6GiJQfZpZZ25XvESSSsxyHE0dAs7SSmX3SlHtEVGmIX0zPLwWZ4NmUBhA+fI nA8aDjI6PaewWcadtzbtYeWDXgzBOgzKYwMQZ6d3/hCi/hBbAe19+95r919fQf3BX55z W8T+XH8vvB5zNbH/+RtfX/AfIp3yQyhHJ6dreIqdG6IJaY7WERnD0jObMPpRo3p0Njp2 ARMElv61FWa3dkpIpuvSnj4/+BOVVMDn/eABPdGnJ8+Q4jmpiHbAGijuxLVVPJ1d/EYb KNRL7HsFF/5j/VjljH/Bn2NBU+Wy2m7QMsrue3nwUUsGgXahndvmjN1j6aGXB3ZyL1mM 3OCw== X-Gm-Message-State: ACgBeo1Vz3V5X+lmSROgGiKBeEBSfiK1rgoaoie+DAqkMW/HTBid3i3C 1oiyMwlX6bCeM0M0rz8hxazw/zsunCI= X-Google-Smtp-Source: AA6agR7PFmOxHM5zrPUQbf97bJJysh9wFvbB4YSBIDiMji25uX248K1JQnRtckQO0CAa1BFwOr9wNg== X-Received: by 2002:a05:6870:3121:b0:113:929e:817d with SMTP id v33-20020a056870312100b00113929e817dmr6257103oaa.48.1660065505540; Tue, 09 Aug 2022 10:18:25 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id f12-20020a056870548c00b000f2455e26acsm3249135oan.48.2022.08.09.10.18.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 10:18:25 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------wCJByNKdM6IjKRZC7riRHy3Y" Message-ID: <3ff41470-0eb2-0f29-86c3-86c37dd15f20@gmail.com> Date: Tue, 9 Aug 2022 12:18:24 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: How to fully restore a single table from a custom dump? Content-Language: en-US To: Pgsql-admin References: <1622540476.1110533.1660049347030@email.ionos.com> <9ca2d8ca-a175-630e-e449-48c2dee5e0f6@jakobs.com> <93797605-23dc-de94-d49e-0849475ad426@gmail.com> From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------wCJByNKdM6IjKRZC7riRHy3Y Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/9/22 12:13, Guillaume Lelarge wrote: > Le mar. 9 août 2022, 18:41, Ron 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 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. --------------wCJByNKdM6IjKRZC7riRHy3Y Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.
--------------wCJByNKdM6IjKRZC7riRHy3Y--