<!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. 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.
</div>
<div class="default-style">
</div>
<div class="default-style">
Regards,
</div>
<div class="default-style">
Michael Vitale
</div>
<div class="default-style">
</div>
<blockquote type="cite">
<div>
On 08/09/2022 8:06 AM EDT Thomas Kellerer <<a href="mailto:shammat(at)gmx(dot)net">shammat(at)gmx(dot)net</a>> wrote:
</div>
<div>
</div>
<div>
</div>
<div>
Hello,
</div>
<div>
</div>
<div>
I just realized that using
</div>
<div>
</div>
<div>
pg_restore -t some_table ... some_dump_file
</div>
<div>
</div>
<div>
doesn't restore things like identity attributes
</div>
<div>
or indexes on the specified table.
</div>
<div>
</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>
</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>
</div>
<div>
Any ideas, how I can _fully_ restore a single table from a custom dump?
</div>
<div>
</div>
<div>
Thomas
</div>
</blockquote>
</body>
</html>