Search Postgresql Archives

Re: Restoring 2 Tables From All Databases Backup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux