summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1997-01-16 15:28:34 +0000
committerBruce Momjian1997-01-16 15:28:34 +0000
commit3d97a61a60f52e400891ee0c8f161920277a130a (patch)
treef139a754a7bd785e4affdad31b146f730b2813a3
parent3a02ccfa1d3e9f643c65fd2d1584f77715b96d36 (diff)
Added pg_dumpall to source tree.
-rw-r--r--src/bin/pg_dump/Makefile3
-rw-r--r--src/bin/pg_dump/pg_dumpall36
-rw-r--r--src/man/pg_dumpall.117
3 files changed, 55 insertions, 1 deletions
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 6a79dd05942..97d50c40843 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -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
index 00000000000..854622043d1
--- /dev/null
+++ b/src/bin/pg_dump/pg_dumpall
@@ -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
index 00000000000..d7eec0a2da5
--- /dev/null
+++ b/src/man/pg_dumpall.1
@@ -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)