Re: How to fully restore a single table from a custom dump?

From: MichaelDBA Vitale <michaeldba(at)sqlexec(dot)com>
To: Thomas Kellerer <shammat(at)gmx(dot)net>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to fully restore a single table from a custom dump?
Date: 2022-08-09 12:49:07
Message-ID: 1622540476.1110533.1660049347030@email.ionos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div>
Hi,
</div>
<div class="default-style">
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.&nbsp; &nbsp;You run pg_restore once to generate the listing.&nbsp; Then run pg_restore again using that modified listing to load into the target database. See the pg_restore docs for exact syntax.
</div>
<div class="default-style">
&nbsp;
</div>
<div class="default-style">
Regards,
</div>
<div class="default-style">
Michael Vitale
</div>
<div class="default-style">
&nbsp;
</div>
<blockquote type="cite">
<div>
On 08/09/2022 8:06 AM EDT Thomas Kellerer &lt;<a href="mailto:shammat(at)gmx(dot)net">shammat(at)gmx(dot)net</a>&gt; wrote:
</div>
<div>
&nbsp;
</div>
<div>
&nbsp;
</div>
<div>
Hello,
</div>
<div>
&nbsp;
</div>
<div>
I just realized that using
</div>
<div>
&nbsp;
</div>
<div>
pg_restore -t some_table ... some_dump_file
</div>
<div>
&nbsp;
</div>
<div>
doesn't restore things like identity attributes
</div>
<div>
or indexes on the specified table.
</div>
<div>
&nbsp;
</div>
<div>
The dump contains much more than just that table, so simply
</div>
<div>
using pg_restore without -t is not an option.
</div>
<div>
&nbsp;
</div>
<div>
While I could extract the indexes manually using some clever regex
</div>
<div>
on the index names, I don't see a way to make sure that identity
</div>
<div>
definitions (or sequence values) are restored properly for the selected table.
</div>
<div>
&nbsp;
</div>
<div>
Any ideas, how I can _fully_ restore a single table from a custom dump?
</div>
<div>
&nbsp;
</div>
<div>
Thomas
</div>
</blockquote>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.0 KB

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Holger Jakobs 2022-08-09 13:21:33 Re: How to fully restore a single table from a custom dump?
Previous Message Thomas Kellerer 2022-08-09 12:06:03 How to fully restore a single table from a custom dump?