Re: How to get single table data from backup

Ray O'Donnell <ray@rodonnell.ie>

From: Ray O'Donnell <ray@rodonnell.ie>
To: Andrus <kobruleht2@hot.ee>, pgsql-general <pgsql-general@postgresql.org>
Date: 2025-12-19T16:12:40Z
Lists: pgsql-general
On 19/12/2025 12:41, Andrus wrote:

> Hi!
>
> Large database backup is created using
>
> pg_dump -b -f backup.backup -F c
>
> How to restore single table in schema firma2 from it in Windows?
>
> Created database recovery and tried
>
> pg_restore --schema-only --n firma2 -d recovery backup.backup
> pg_restore -n firma2 -t tabletorecover -d recovery backup.backup
>
> This fails since tabletorecover contains lot foreign key references. 
> Foreign keys refer to other tables which have foreign keys to another 
> tables etc. making huge graph. All tables contain also data.
>
I haven't tried it, but - off the top of my head - how about:

(i) Create the table separately by hand, without the FK references.

(ii) Do a data-only restore, using the -a and -t options to pg_restore


Ray.




> I need to get table data only. Using PostgresSql 17 in windows.
>
> Andrus.
>
>
-- 
Ray O'Donnell // Galway // Ireland
ray@rodonnell.ie