Thread: Validade dump file

Validade dump file

From
Fábio Gibon - Comex System
Date:
Hi everybody,
        are there some tool or internal program that read a dump file (created by pg_dump) and list all tables and number of tuples (without
restore) in this file?
 
        And too, are there some tool to check the physical file integrity? (S.O. Windows)
 
thanks
Fábio Henrique Gibon
 

Re: Validade dump file

From
Guillaume Lelarge
Date:
Le 05/10/2010 05:28, Fábio Gibon - Comex System a écrit :
> [...]
> are there some tool or internal program that read a dump file (created by pg_dump) and list all tables and number of
tuples(without  
> restore) in this file?
>

That command should give you the number of tables in your plain dump:

  grep "CREATE TABLE" your_dump_file | wc -l

If you have a binary dump (ie, tar or custom), you should do this:

  pg_restore -s your_dump_file | grep "CREATE TABLE" | wc -l

There's no easy way to get the number of tuples in each table.

> And too, are there some tool to check the physical file integrity? (S.O. Windows)

notepad? :)

I mean, with a SQL file, this is just a bunch of SQL queries. So there's
no real way to check the file integrity without restoring it.

On a binary dump, you can do a "pg_restore your_dump_file > /dev/null".
It should warn you if you have an integrity issue.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: Validade dump file

From
Willy-Bas Loos
Date:
cool actually.
any idea for the number of tuples?
count all lines after COPY .* ) FROM stdin;
until \.
(but how?)

on a side note: what's the difference between the admin list and the general list?


--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw

Re: Validade dump file

From
"Kevin Grittner"
Date:
Willy-Bas Loos <willybas@gmail.com> wrote:

> any idea for the number of tuples?

Your best bet would be to use whatever scripting language you like
which has decent support for regular expressions.  Expect to tweak
your expressions a bit as you discover the corner cases where you're
not getting the count you expect.

> on a side note: what's the difference between the admin list and
> the general list?

This thread is OK on admin -- which is targeted toward operational
issues.  If in doubt, general can include just about anything.  It
gets traffic about equal to all the more specific lists combined, so
it's a bit much for some of us to follow.  Some people (like me) who
can't absorb the volume of traffic on general follow a few more
specialized lists where we feel we're best able to help.  If
discussion on one list dies out without a satisfactory resolution,
it's OK to try another likely-looking list -- particularly if
there's no further repsonse on the initial list for a few days.
While there's a fair amount of overlap, you will get a somewhat
different set of people tracking each list.

-Kevin