You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modify pg_dumpall so that output script uses new OWNER option of CREATE
DATABASE; also make it use SET SESSION AUTHORIZATION commands rather than
\connect commands. This makes it possible to restore databases belonging
to users who do not have CREATEDB privilege. It should also become at
least somewhat feasible to run the restore script under password
authentication --- you'll get one superuser password prompt per database,
rather than a large number of challenges for passwords belonging to
varying unspecified user names.
# For each database, run pg_dump to dump the contents of that database.
210
+
# To minimize the number of reconnections (and possibly ensuing password
211
+
# prompts) required by the output script, we emit all CREATE DATABASE
212
+
# commands during the initial phase of the script, and then run pg_dump
213
+
# for each database to dump the contents of that database.
210
214
# We skip databases marked not datallowconn, since we'd be unable to
211
215
# connect to them anyway (and besides, we don't want to dump template0).
212
216
217
+
DATABASES=""
218
+
213
219
$PSQL -d template1 -At -F '' \
214
220
-c "SELECT datname, coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), pg_encoding_to_char(d.encoding), datistemplate, datpath FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) WHERE datallowconn ORDER BY 1;"| \
0 commit comments