Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lv4Fu-0006oG-UC for pgsql-general@arkaria.postgresql.org; Sun, 20 Jun 2021 20:41:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lv4FO-0002gD-2z for pgsql-general@arkaria.postgresql.org; Sun, 20 Jun 2021 20:40:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lv4FN-0002g5-P9 for pgsql-general@lists.postgresql.org; Sun, 20 Jun 2021 20:40:49 +0000 Received: from mout.gmx.net ([212.227.17.22]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lv4FL-0002DJ-9f for pgsql-general@lists.postgresql.org; Sun, 20 Jun 2021 20:40:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1624221640; bh=xO5F6+vPoRlLPEfDnA8EfwlNXcgPCcOPfAu9zmwizLc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=D2dVcgmo7RBdHo2N5LSb/Nl8tyCPqG8dY93kSEPRt3/VvxoUYh9sYHbMLIfTfHNGO YQw5a1QuvpMtcr9spZQVEkCLoD3+/6jzyZ6FbyyZL+VaZQyF5ZmH2gipBptYkBGDOj lbGtFLHSj/b4J0dAkE80XAA0cR9J+DSEMy2nGaqQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([78.55.9.221]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MI5QF-1m6JjT0DjT-00FA9g; Sun, 20 Jun 2021 22:40:40 +0200 Received: from ncq by hermes with local (Exim 4.94.2) (envelope-from ) id 1lv4FC-0005sU-El; Sun, 20 Jun 2021 22:40:38 +0200 Date: Sun, 20 Jun 2021 22:40:38 +0200 From: Karsten Hilbert To: Adrian Klaver Cc: Tom Lane , pgsql-general@lists.postgresql.org Subject: Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2 Message-ID: References: <1511776.1624211267@sss.pgh.pa.us> <3d842ba4-13c1-cd95-8ef9-b69a06eeb6c1@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3d842ba4-13c1-cd95-8ef9-b69a06eeb6c1@aklaver.com> Ma_X_il-Followup-to: d Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net X-Pri_X_ority: 2 (High) Sender: X-Provags-ID: V03:K1:kHqtBfSvRQeHD+YiYuXb7AxCQA0THqi9mjIpRQ56Omui6wGxeRo wyrBHPRLkO8HrfSL194NqW/bHOe2qzkhzGOUy/pAn51/J+LTCJTAlZAFzmfRi6qMjOTK1yJ u/M3cMCihjeTkaqSMI/tnAh/KGHxrN7EZOnE7nuDT5YPLsvTln/aCLwVuqX1xhbNErr/4AJ RdRmyteM9tMC8Z29XOXTg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VPLKwa4iWUw=:vvTJhz0WAiKM0L/qEqe8uI gVLhV6KnJNyUKXTCcXHZGNVrGlzpO96CI/4cGv3qt2XZF/uvGmLRTTX6uwgg6iIZEPGNU/ami ca2gDtdlplnQD+1pCS7vEog0KJjyWPgNR0SDbAxxi84DpdEDyDsLbG8TF7/QjHb10iCnTQT7H UYZDEMhMHE5Bk9/GpclXyqKzQl3dCcnoc0+fUNha8nCjpTekLFNV7tPgki1sYpldMN3rwQeij nr3/2sFORxMYbrv/iNujt1J58IQKCTRBKl+wSDOy5baftja+ZQcASrLSbP6PQ8MQb4j0PnJIw 0mg/70jPlcl3W4IRseAjHh39u1kjnzEk56kznqE78JWT2b9/eYAtaubD2e2DuKc728kAOBtNZ z9r6jYepC+rCP+j5jmVjTNdw+pWlEf57TrPgZnNGN8/TPafK6hi6cxUdyGfmdssbuh2le3w6n GqoeaVdKYjXqpcHLhYbS25WQDPQCTU3mL+JX18+3uJ8mz0+iLVMn4SxQSFHBn/IvkzFdefGHD b7O+iJqkR3bLaYl5mr6EoU6dKWufNHuLe8dRrW30YGd2LyakeIRq9RnGmqSiw8ZnY47lkpkyz JCFd2nS0oYukTYwzcf/yP9LDQXGWBkaih6n3wzSLJmTCUY2XuoYdzwUG2t7AAiizHNSp75u7U LPd3ctGOW9qXUNHzeYcAR648I2PAc8Bhl4D9r7zT/Xk1GHwMMRDplt5gPgG3jxF3g5kKlZ9mL tgEEdmnAMOnyb0nUfO/kbk31RMynpNqoBMQ3cqA8qlzZLKdZeFJzot8LitvSIOzdhx5VXduLT dBRrb8n0X1jnkVqZLu5t/kL4XsnD6iBA3P+X6aoI8ahlh0bjTOizKE1gac0JLqYSn/vfG3sJw LhtlVc6avTnEWGPI85L0C8vDkIuEIsFZKinPsRaSrAyopCP4PgJ1nYZdu1ZOXI1FodkqA2Otu xWuMxbjt5tN9emyRpwL7WOKtKEY+nQNPLVww3tMN5sYlGs5px1cc6HdvcHrz385LbDlxRLYMn 1e/25U7MotkUvKhLVhoHs7VjglFQsJwJ7XqUIFLZRVFg2KYRw+jwLFNqg4IE0cdakG/t85HAh SjNZUzdm8rLOLqo0gC5ceVAxEqodWan1EXjeUhisxDwR2ENi9LJhjjATA== Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am Sun, Jun 20, 2021 at 01:14:06PM -0700 schrieb Adrian Klaver: > >Any chance pg_dump (and/or pg_restore) might gain an option > >--ignore-read-only ? That way, PostgreSQL need not decide > >for users. > > How about: > > 1) pg_dump -Fc -d read_only_db -U postgres -f read_only.out > > 2) In new cluster: > A) psql -d postgres -U postgres > CREATE DATABASE read_only; > > B) pg_restore -d read_only -U postgres read_only.out > > C) psql -d read_only -U postgres > alter database read_only SET default_transaction_read_only TO 'on'; That would work but does not lend itself well to a fully scripted pg_dump/pg_restore backup "solution". The full pg_dump command line is this: pg_dump --verbose --format=3Ddirectory --compress=3D0 --column-inserts --= clean --if-exists --serializable-deferrable "${_PG_HOST_ARG}" "${_PG_PORT_= ARG}" --username=3D"${GM_DBO}" -f "${BACKUP_DATA_DIR}" "${GM_DATABASE}" 2>= /dev/null And this is the restore: sudo -u postgres pg_restore --verbose --create --dbname=3Dtemplate1 --exi= t-on-error -p ${GM_PORT} ${BACKUP}.dir/ Thanks, Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B