44# dumps all databases to standard output
55# It also dumps the pg_user table
66#
7+ # to adapt to System V vs. BSD 'echo'
8+ set -x
9+ if echo ' \\' | grep' \\\\' > /dev/null2>&1
10+ then
11+ BS=' \' # BSD
12+ else
13+ BS=' \\' # System V
14+ fi
715psql -l -A -q -t| cut -d" |" -f1| grep -v' ^template1$' | \
816while read DATABASE
917do
10- /bin/ echo' \ connect template1'
11- /bin/ echo" create database$DATABASE ;"
12- /bin/ echo' \ connect' " $DATABASE "
18+ echo " ${BS} connect template1"
19+ echo " create database$DATABASE ;"
20+ echo " ${BS} connect$DATABASE "
1321pg_dump" $@ " $DATABASE
1422done
15- /bin/ echo' \ connect template1'
16- /bin/ echo' copy pg_user from stdin;'
23+ echo " ${BS} connect template1"
24+ echo " copy pg_user from stdin;"
1725#
1826# Dump everyone but the postgres user
1927# initdb creates him
2028#
21- POSTGRES_SUPER_USER_ID=" ` psql -q template1<< END
22- \\ t
29+ POSTGRES_SUPER_USER_ID=" ` psql -A -q -t template1<< END
2330select datdba
2431from pg_database
2532where datname = 'template1';
@@ -31,4 +38,4 @@ where usesysid <> $POSTGRES_SUPER_USER_ID;
3138copy tmp_pg_user to stdout;
3239drop table tmp_pg_user;
3340END
34- /bin/ echo'\.'
41+ echo" ${BS} . "