Re: Restoring 2 Tables From All Databases Backup - Mailing list pgsql-general

From Filip Rembiałkowski
Subject Re: Restoring 2 Tables From All Databases Backup
Date
Msg-id CAP_rwwkgUMMR6+WLgAXafKLUB20B0CxxQ+feVdMWo27jmyvZtg@mail.gmail.com
Whole thread Raw
In response to Restoring 2 Tables From All Databases Backup  (Adarsh Sharma <adarsh.sharma@orkash.com>)
List pgsql-general


2011/10/5 Adarsh Sharma <adarsh.sharma@orkash.com>
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.





pgsql-general by date:

Previous
From: salah jubeh
Date:
Subject: Re: how to disable all pkey/fkey constraints globally
Next
From: tushar nehete
Date:
Subject: How to create database link and synonym in postgresql 9.0