mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
Allow pg_dumpall to preserve database ownership.
This commit is contained in:
parent
029873a109
commit
2fc04874a6
@ -5,18 +5,19 @@
|
|||||||
# It also dumps the pg_user table
|
# It also dumps the pg_user table
|
||||||
#
|
#
|
||||||
# to adapt to System V vs. BSD 'echo'
|
# to adapt to System V vs. BSD 'echo'
|
||||||
set -x
|
#set -x
|
||||||
if echo '\\' | grep '\\\\' >/dev/null 2>&1
|
if echo '\\' | grep '\\\\' >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
BS='\' # BSD
|
BS='\' # BSD
|
||||||
else
|
else
|
||||||
BS='\\' # System V
|
BS='\\' # System V
|
||||||
fi
|
fi
|
||||||
psql -l -A -q -t|cut -d"|" -f1 | grep -v '^template1$' | \
|
psql -l -A -q -t|cut -d"|" -f1-2 | tr '|' ' ' | grep -v '^template1 ' | \
|
||||||
while read DATABASE
|
while read DATABASE USER
|
||||||
do
|
do
|
||||||
echo "${BS}connect template1"
|
echo "${BS}connect template1"
|
||||||
echo "create database $DATABASE;"
|
echo "create database $DATABASE;"
|
||||||
|
echo "update pg_database set datdba = $USER where datname = '$DATABASE';"
|
||||||
echo "${BS}connect $DATABASE"
|
echo "${BS}connect $DATABASE"
|
||||||
pg_dump "$@" $DATABASE
|
pg_dump "$@" $DATABASE
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user