OSDN Git Service

Added pg_dumpall to source tree.
authorBruce Momjian <bruce@momjian.us>
Thu, 16 Jan 1997 15:28:34 +0000 (15:28 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 16 Jan 1997 15:28:34 +0000 (15:28 +0000)
src/bin/pg_dump/Makefile
src/bin/pg_dump/pg_dumpall [new file with mode: 0644]
src/man/pg_dumpall.1 [new file with mode: 0644]

index 6a79dd0..97d50c4 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.11 1996/11/28 03:31:27 bryanh Exp $
+#    $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.12 1997/01/16 15:28:21 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -35,6 +35,7 @@ submake:
 
 install: pg_dump
        $(INSTALL) $(INSTL_EXE_OPTS) pg_dump $(DESTDIR)$(BINDIR)/pg_dump
+       $(INSTALL) $(INSTL_EXE_OPTS) pg_dumpall $(DESTDIR)$(BINDIR)/pg_dumpall
 
 depend dep:
        $(CC) -MM $(INCLUDE_OPT) *.c >depend
diff --git a/src/bin/pg_dump/pg_dumpall b/src/bin/pg_dump/pg_dumpall
new file mode 100644 (file)
index 0000000..8546220
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# pg_dumpall [pg_dump parameters]
+# dumps all databases to standard output
+# It also dumps the pg_user table
+#
+psql -l -A -q -t|unesc|cut -d"|" -f1 | grep -v '^template1$' | \
+while read DATABASE
+do
+       /bin/echo '\connect template1'
+       /bin/echo "create database $DATABASE;"
+       /bin/echo '\connect' "$DATABASE"
+       pg_dump "$@" $DATABASE
+done
+/bin/echo '\connect template1'
+/bin/echo 'copy pg_user from stdin;'
+#
+# Dump everyone but the postgres user
+# initdb creates him
+#
+POSTGRES_SUPER_USER_ID="`psql -q template1 <<END
+\\t
+select datdba 
+from pg_database
+where datname = 'template1';
+END`"
+psql -q template1 <<END
+select pg_user.* into table tmp_pg_user
+from pg_user
+where usesysid <> $POSTGRES_SUPER_USER_ID;
+copy tmp_pg_user to stdout;
+drop table tmp_pg_user;
+END
+/bin/echo '\.'
+
+
diff --git a/src/man/pg_dumpall.1 b/src/man/pg_dumpall.1
new file mode 100644 (file)
index 0000000..d7eec0a
--- /dev/null
@@ -0,0 +1,17 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_dumpall.1,v 1.1 1997/01/16 15:28:34 momjian Exp $
+.TH pg_dumpall UNIX 1/20/96 PostgreSQL PostgreSQL
+.SH NAME
+pg_dumpall \(em dumps out all Postgres databases into a script file
+.SH SYNOPSIS
+.BR pg_dumpall 
+[pg_dump options]
+.SH DESCRIPTION
+.IR "pg_dumpall"
+is a utility for dumping out all Postgres databases into one file.
+It also dumps the pg_user table, which is global to all databases.
+pg_dumpall takes all pg_dump options, but \fB-f\fR and \fBdbname\fR
+should not be used.
+.SH "SEE ALSO"
+pg_dump(1)