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 1kOnJg-0007mj-Hj for pgsql-general@arkaria.postgresql.org; Sat, 03 Oct 2020 19:35:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kOnJc-0002iD-T8 for pgsql-general@arkaria.postgresql.org; Sat, 03 Oct 2020 19:35:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kOnJb-0002i6-Q1 for pgsql-general@lists.postgresql.org; Sat, 03 Oct 2020 19:35:32 +0000 Received: from agree-14.godzone.net.nz ([192.138.251.14] helo=smtp.godzone.net.nz) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kOnJU-0006IF-Nd for pgsql-general@lists.postgresql.org; Sat, 03 Oct 2020 19:35:28 +0000 Received: from agree-20.godzone.net.nz (agree-20.godzone.net.nz [IPv6:2406:1e00:b410:2301::20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.godzone.net.nz (Postfix) with ESMTPSA id 07C7F859B1E for ; Sun, 4 Oct 2020 08:35:16 +1300 (NZDT) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.godzone.net.nz 07C7F859B1E Authentication-Results: smtp.godzone.net.nz; dmarc=fail (p=none dis=none) header.from=godzone.net.nz Authentication-Results: smtp.godzone.net.nz; spf=fail smtp.mailfrom=geustace@godzone.net.nz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=godzone.net.nz; s=default; t=1601753717; bh=icxPtKxdt4nuDwuTFxBu6mj7ExcMQZHY8fU4ZLYOwXk=; h=Subject:To:References:From:Date:In-Reply-To; b=ua2cAkPzFIwItcXUzt/GDdbjyTixs9unvh3R8dh92RDFfXvKoc7IJu5VAYZlIzbvz jc5phCUx53v27ZYXw5nmoajert4N0p+le1hHRbzZ87/nF/BoseRFJ77s3K7XgLssSB 2wUQAQGTcoq9Mfs+qmlsh0YSFdmIhGtIi/dtszKE= Subject: Re: Restoring a database problem To: pgsql-general@lists.postgresql.org References: <20201001001100.GC26860@momjian.us> <82097994-6772-dfd7-84e0-8f150af25e26@gmail.com> <20201003113050.GC18543@hjp.at> From: Glen Eustace Autocrypt: addr=geustace@godzone.net.nz; keydata= xsFNBFp5EywBEAC8HqIcbCmRNl7EHwpctByvlb7kBDrA7UdDnJ83G/e4PzljdO0KhmCLm4kL jFLJLnJyqB/W0FfM2KksGiygXGSQPbTd4j03IVhH4XKF8j7oIeV1qWXcAuJmKyJakc7a1DtG 8+clrTYNwmtDUiG8LczRGIqJkKJJ3bc82vkBY+nwOId/5XTaDOf/nScnitCx4wPRZ9qoC8nb aPGnK2i7UC8kyP43AId6iAsDHvJ1Twitm844Zkx8Q0meKxwXwmvTvgxo7wEgDpBuovL2fXFP mPcI3R41+n/Op/TFsCsyaHwoYGkAmWbP+nnsUgPGYA55KM8QzpX65zMT2CQmtCJ2MqhGYCtb JMHNELOD4/bYEeSn81splIhXMpifCyI9Oh40uSU5x7EfR6MdQuTyj6A+unMiMwzGB8CirlC9 xVTRPwuwjHXrWEuCEansupW4toh/CmqVYAWkIzSacnKzZKuELqTeBAcNduUmKxzNVF4sPlkV LFL7lR5NutkDu/mK8ba19IJxs9O93+ug00Mbme3aZS0sD3T0dlF0CioTb8Ri+Y3FdmX1Qf2/ 1d//ZQavkVBIuvRH9lsemLsqE1NiKr2QhwJTwmyzEIECeihWEgH6ClxJhV7gq0ucuGko+1FN YiJy9U1TLu+RXm7WlcsIsJ7ciwxS0BeMwPUYxDrEaP4Ijs8ZLQARAQABzSZHbGVuIEV1c3Rh Y2UgPGdldX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LyTM41R+Q3IQWIPWKPU6UdwmXo6wtkTDXEzH3icWmyn10XAb/yf feotmGKKIz9XlacT0ynIhlYAMnM7DVQB4GB8K3pf3733Tyhu/KYB0BpmaZahyioqJX7p0/9z y/JI/O970n7KxECWp5XUEW9Y8n4z/5FVL+ViyNtGCAtf0Hu47BLg29RTCmyk6qWU Organization: GodZone Internet Services Message-ID: <86ff9561-b8a7-501e-581e-4cecf3296b78@godzone.net.nz> Date: Sun, 4 Oct 2020 08:35:12 +1300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201003113050.GC18543@hjp.at> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AsItT1y98SPbVubm03KK69JIUOk0Fk9nK" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AsItT1y98SPbVubm03KK69JIUOk0Fk9nK Content-Type: multipart/mixed; boundary="E8hrRhFdd3MGz6HKJgfhj6VclclTbNj7T" --E8hrRhFdd3MGz6HKJgfhj6VclclTbNj7T Content-Type: multipart/alternative; boundary="------------CF0BEABD750CC6B39B7079E7" Content-Language: en-NZ This is a multi-part message in MIME format. --------------CF0BEABD750CC6B39B7079E7 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable > I need to close all existing connections and the prevent people/process= es from > connecting again until the restore has completed. I was hoping there was a command in psql that would do both, that is, kick the exisiting connections and stop new ones.=A0 It was being a bit optimistic I think, but such a command would be really useful, IMHO. Modifying pg_hba.conf, is a little complicated. The daemons are using the db owner's credential and the backups are on a different server so I still need to be able to connect to do the restore. I guess I will need something like local=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 r= eject host=A0=A0=A0 mydb=A0=A0=A0 postgres=A0=A0=A0 0.0.0.0/0=A0=A0=A0 password= host=A0=A0=A0 mydb=A0=A0=A0 postgres=A0=A0=A0 ::0/0=A0=A0=A0 =A0=A0=A0 pa= ssword host=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0 =A0 0.0.0.0/0=A0=A0=A0 reject host=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0 =A0=A0=A0 ::0/0=A0=A0=A0 reject then systemctl reload postgresql-10 then from the server with the backup on it pg_restore -h db-server -Upostgres -c -C -d mydb mydb-backup Modifying pg_hba isnt going to kick the existing connections, so I will need to do that either using psql and the commands in the article Rob posted, (I think I have used that method somewhere already). or kill them on the DB server --=20 =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D Glen Eustace, GodZone Internet Services, a division of AGRE Enterprises Ltd., P.O. Box 8020, Palmerston North, New Zealand 4446 Ph +64 6 357 8168, Mob +64 27 542 4015 =93Specialising in providing low-cost professional Internet Services sinc= e 1997" --------------CF0BEABD750CC6B39B7079E7 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
=
I need to close all existing=
 connections and the prevent people/processes from
connecting again until the restore has completed.
I was hoping there was a command in psql= that would do both, that is, kick the exisiting connections and stop new ones.=A0 It was being a bit optimistic I think, but such a= command would be really useful, IMHO.

Modifying pg_hba.conf, is a little complicated. The daemons are using the db owner's credential and the backups are on a different server so I still need to be able to connect to do the restore.

I guess I will need something like
=

local=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0= =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 reject
host=A0=A0=A0 mydb=A0=A0=A0 postgres=A0=A0=A0 0.0.0.0/0=A0=A0=A0 pa= ssword
host=A0=A0=A0 mydb=A0=A0=A0 postgres=A0=A0= =A0 ::0/0=A0=A0=A0 =A0=A0=A0 password
host=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0 =A0 0.0.0.0/0=A0=A0=A0 rej= ect
host=A0=A0=A0 mydb=A0=A0=A0 all=A0=A0=A0= =A0=A0=A0 ::0/0=A0=A0=A0 reject

then systemctl reload postgresql-10

then from the server with the backup on it
pg_restore -h db-server -Upostgres -c -C -d mydb mydb-backup

Modifying pg_hba isnt going to kick the existing connections, so I will need to do that either using psql and the commands in the article Rob posted, (I think I have used that method somewhere already). or kill them on the DB server

--
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D
Glen Eustace,
GodZone Internet Services, a division of AGRE Enterprises Ltd., P.O. Box 8020, Palmerston North, New Zealand 4446 Ph +64 6 357 8168, Mob +64 27 542 4015

=93Specialising in providing low-cost professional Internet Services since 1997"
--------------CF0BEABD750CC6B39B7079E7-- --E8hrRhFdd3MGz6HKJgfhj6VclclTbNj7T-- --AsItT1y98SPbVubm03KK69JIUOk0Fk9nK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEECQBPiIxFtk5tx0+S3YRsFWDpo7oFAl940nIACgkQ3YRsFWDp o7rmmRAAigi62LM+ximKzW79ivTHMpWHU6eir3iHvhdw2fFU+dHL+3Z3QT96/rI+ yCAx89BYzw/rSXt5FJ/mdX6KatK9j8h5ffRl8lh1BAthj6gQh82IvpTNUZsE+LsZ JlZ/e9dXM6RXChgBnF5ZDmnkhub+0rQYWJkFa/vFDhpPI6M4laZiie1eb3lrWFn5 XaLYZ1ep/yaebZjYitWzEYhivPZ1i+bxRSTNb/mJg+e09dgt6V0EhhR2fqxnV2H3 1+5t4JnH/DU7N7jGjCncl0qcdLTogQfbO5IwMbEVGvz8FEWk79e8kuQJPQ9btM9V XViAWKH8lqhmrV6O0cY3Nej05UI7puylonatglja9vf2pv8X1mczvuqrpG92h7xl 6KfKsNo6wL22OX6aBUaLIfO3u53tbw1scRm8NUOXdpmdv6dcNpXkMmnlWQxCjhiM pC3NHxflu6+RyAFW3JzK4BqMp/3QdHRqDqPuycgK0cJoVWDXmwL9iKYQqRS/qCSh lyPRpEVFDzcQNIIUVcWeHTH+pDoYlxRapY011kjsE6doik56ynQPPNhDeS0/uhvi FqqyYwFeXp1rYahasIo9h8W4v164mNRlXwWwONWHkFVAD6rc3hekJueSz7dGsa9g mF619UO/VPj9acsM1pCa6KjuY+rK7Hqoif0an7DGHsyHyvOoPAo= =7fpF -----END PGP SIGNATURE----- --AsItT1y98SPbVubm03KK69JIUOk0Fk9nK--