How to extract parts of a bzipped PostgreSQL dump

164 views Asked by At

I have a PostgreSQL plain format dump and need only two or three tables' data. The dump is in gz2 format.

bzcat dump.sql.gz | perl -lne 'print if /^COPY tablename/../^\\\.$/' > something.sql

not working. also tried

bzip2 -dc dump.sql.gz|perl -lne 'print if /^COPY tablename/../^\\\.$/' > something.sql

The dump file is more than 30GB.

1

There are 1 answers

0
jjanes On

The table name probably needs to be schema-qualified.

whatever_cat | perl -lne 'print if /^COPY public\.tablename/../^\\\.$/'

This will depend on the version of pg_dump being used. The change actually kicks in in a bug-fix release, is it was the result of a security concern (CVE-2018-1058)