2
2
#
3
3
# pg_dumpall [pg_dump parameters]
4
4
# dumps all databases to standard output
5
- # It also dumps the pg_shadow table
5
+ # It also dumps the pg_shadow and pg_group tables, which belong to the
6
+ # whole installation rather than any one individual database.
7
+ #
8
+ # $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall,v 1.25 2000/05/05 03:04:00 tgl Exp $
6
9
#
7
10
# to adapt to System V vs. BSD 'echo'
8
- # set -x
9
11
if echo ' \\' | grep ' \\\\' > /dev/null 2>&1
10
12
then
11
13
BS=' \' # BSD
@@ -36,6 +38,8 @@ echo "delete from pg_shadow where usesysid <> tmp_pg_shadow.datdba;"
36
38
echo " drop table tmp_pg_shadow; "
37
39
#
38
40
# load all the non-postgres users
41
+ # XXX this breaks badly if the layout of pg_shadow ever changes.
42
+ # It'd be better to convert the data into CREATE USER commands.
39
43
#
40
44
echo " copy pg_shadow from stdin; "
41
45
psql -q template1 <<END
@@ -47,6 +51,19 @@ copy tmp_pg_shadow to stdout;
47
51
drop table tmp_pg_shadow;
48
52
END
49
53
echo " ${BS} ."
54
+ #
55
+ # copy the pg_group table too
56
+ # XXX this breaks badly if the layout of pg_group ever changes.
57
+ # It'd be better to convert the data into CREATE GROUP commands.
58
+ #
59
+ echo " copy pg_group from stdin; "
60
+ psql -q template1 <<END
61
+ copy pg_group to stdout;
62
+ END
63
+ echo " ${BS} ."
64
+ #
65
+ # For each database, run pg_dump to dump the contents of that database.
66
+ #
50
67
psql -A -q -t -c " select * from pg_database" template1 | grep '|' | tr '|' ' ' | \
51
68
grep -v '^template1 ' | \
52
69
while read DATABASE DBUSERID ENCODING DATAPATH
73
90
exit 1
74
91
fi
75
92
done
93
+
94
+ exit 0
0 commit comments