Re: Would you add a --dry-run to pg_restore?

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Edmundo Robles <edmundo(at)sw-argos(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Would you add a --dry-run to pg_restore?
Date: 2017-08-03 08:25:05
Message-ID: CA+bJJbxszmt7Pd8Xfrp2QFGbvQHLQ=aX2iomzO=S37D=JtG_=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 2, 2017 at 7:10 PM, Edmundo Robles <edmundo(at)sw-argos(dot)com> wrote:
>
> I imagine pg_restore can execute the instructions on dump but don't write on disk. just like David said: "tell me what is going to happen but don't actually do it"

IIRC pg_restore does not execute SQL fully. It just passes the
commands to the server when in text mode, like psql, and builds some
commands and send them to the server to execute when in custom/tar
mode. I doubt it has the ability to validate the contents of the dump.

>> Edmundo Robles <edmundo(at)sw-argos(dot)com> writes:
>> > I mean, to verify the integrity of backup i do:
>> > gunzip -c backup_yesterday.gz | pg_restore -d my_database && echo
>> > "backup_yesterday is OK"

I also think if he is piping the dump must be text mode, I seem to
recall custom format needs seekable files, but not too sure about tar,
it should not. In this case, as previously suggested, a simple gunzip
-t is enough to verify backup file integrity, but checking internal
correctness is very difficult ( as it may even depend on server
configuration, i.e., needing some predefined users / locales /
encodings ).

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rory Campbell-Lange 2017-08-03 09:02:57 Re: Would you add a --dry-run to pg_restore?
Previous Message Francisco Olarte 2017-08-03 08:14:35 Re: Do not INSERT if UPDATE fails