Re: Restoring 2 Tables From All Databases Backup

Поиск
Список
Период
Сортировка
От Filip Rembiałkowski
Тема Re: Restoring 2 Tables From All Databases Backup
Дата
Msg-id CAP_rwwkgUMMR6+WLgAXafKLUB20B0CxxQ+feVdMWo27jmyvZtg@mail.gmail.com
обсуждение исходный текст
Ответ на Restoring 2 Tables From All Databases Backup  (Adarsh Sharma <adarsh.sharma@orkash.com>)
Список 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 по дате отправления:

Предыдущее
От: salah jubeh
Дата:
Сообщение: Re: how to disable all pkey/fkey constraints globally
Следующее
От: tushar nehete
Дата:
Сообщение: How to create database link and synonym in postgresql 9.0