2011/10/5 Adarsh Sharma <[email protected]>
> Dear all,
>
> About 1 month ago, I take a complete databases backup of my Database server
> through pg_dumpall command.
> Today I need to extract or restore only 2 tables in a database.
>
> Is it possible or I have to restore complete Databases again. Size of
> backup is 10 GB in .sql.gz format.
>
> Please let me know how to extract the tables from this 10Gb backup file
>
>
since this is a plaintext file, not a custom format backup,
you unfortunately need to extract portions of text using some editor or
program...
for this kind of work I would recommend Perl or Awk.
below is my "first shot" - thats incomplete (no restoration of
indexes/sequences):
gunzip -cd all.sql.gz | awk '/^CREATE TABLE mytable /,/^$/ { print }; /^COPY
mytable /,/^$/ { print };'
which does print all lines from CREATE TABLE mytable to next empty line, and
all lines from COPY mytable to next empty line.