pg_dumpall should permit quiet operation - Mailing list pgsql-bugs

From Neil T. Spring
Subject pg_dumpall should permit quiet operation
Date
Msg-id 20020423213730.GA17941@cs.washington.edu
Whole thread Raw
Responses Re: pg_dumpall should permit quiet operation
List pgsql-bugs
pg_dumpall now prints status messages;  I find them to be a
nuisance, and the patch below implements a --quiet option,
though not necessarily well.

thanks,
-neil

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :     Neil Spring
Your email address    : nspring@cs.washington.edu


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : PIII dual 1GHz

  Operating System (example: Linux 2.0.26 ELF)     : Debian Woody / 2.4.18

  PostgreSQL version (example: PostgreSQL-7.2.1):   PostgreSQL-7.2.1

  Compiler used (example:  gcc 2.95.2)        :  2.95.4


Please enter a FULL description of your problem:
------------------------------------------------

pg_dumpall now prints status messages to stderr, which makes
it less suitable for a nightly cron job to backup the
database.   I either get nightly useless mail, or redirect
stderr so that I don't know about errors.  pg_dumpall
should not print those messages, or at least support
a --quiet option.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

type "pg_dumpall > x". watch informational messages appear.



If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

patch to pg_dumpall.sh follows.   A patch to pg_dumpall.1 is
straightforward, assuming this is the way to deal with the problem.

diff -cr postgresql-7.2.1/src/bin/pg_dump/pg_dumpall.sh postgresql/src/bin/pg_dump/pg_dumpall.sh
*** postgresql-7.2.1/src/bin/pg_dump/pg_dumpall.sh    Sun Feb 10 16:18:20 2002
--- postgresql/src/bin/pg_dump/pg_dumpall.sh    Tue Apr 23 14:22:56 2002
***************
*** 87,92 ****
--- 87,96 ----
                  echo "pg_dumpall (PostgreSQL) $VERSION"
                  exit 0
                  ;;
+         --quiet|-q)
+             quiet=t
+             break
+             ;;
      --host|-h)
          connectopts="$connectopts -h $2"
          shift;;
***************
*** 144,149 ****
--- 148,154 ----
      echo "  -g, --globals-only     Only dump global objects, no databases"
      echo "  -h, --host=HOSTNAME    Server host name"
      echo "  -p, --port=PORT        Server port number"
+     echo "  -q, --quiet            Don't print status messages to stderr"
      echo "  -U, --username=NAME    Connect as specified database user"
      echo "  -W, --password         Force password prompts (should happen automatically)"
      echo "Any extra options will be passed to pg_dump.  The dump will be written"
***************
*** 169,175 ****
  echo "DELETE FROM pg_shadow WHERE usesysid <> (SELECT datdba FROM pg_database WHERE datname = 'template0');"
  echo

! echo "connected to template1..." 1>&2
  $PSQL -d template1 -At -c "\
  SELECT
    'CREATE USER \"' || usename || '\" WITH SYSID ' || usesysid
--- 174,180 ----
  echo "DELETE FROM pg_shadow WHERE usesysid <> (SELECT datdba FROM pg_database WHERE datname = 'template0');"
  echo

! [ "$quiet" ] || echo "connected to template1..." 1>&2
  $PSQL -d template1 -At -c "\
  SELECT
    'CREATE USER \"' || usename || '\" WITH SYSID ' || usesysid
***************
*** 235,241 ****
      fi

      echo "${BS}connect \"$DATABASE\" \"$DBOWNER\""
!     echo "dumping database \"$DATABASE\"..." 1>&2
      $PGDUMP "$DATABASE" <&4
      if [ "$?" -ne 0 ] ; then
          echo "pg_dump failed on $DATABASE, exiting" 1>&2
--- 240,246 ----
      fi

      echo "${BS}connect \"$DATABASE\" \"$DBOWNER\""
!     [ "$quiet" ] || echo "dumping database \"$DATABASE\"..." 1>&2
      $PGDUMP "$DATABASE" <&4
      if [ "$?" -ne 0 ] ; then
          echo "pg_dump failed on $DATABASE, exiting" 1>&2

pgsql-bugs by date:

Previous
From: Ian Morgan
Date:
Subject: Re: 7.2.1: pg_dump of UNIONed VIEWs broken
Next
From: Tom Lane
Date:
Subject: Re: 7.2.1: pg_dump of UNIONed VIEWs broken