From: Glen Eustace <geustace@godzone.net.nz>
To: pgsql-general@lists.postgresql.org
Subject: Re: Restoring a database problem
Date: Sun, 4 Oct 2020 08:35:12 +1300
Message-ID: <86ff9561-b8a7-501e-581e-4cecf3296b78@godzone.net.nz> (raw)
In-Reply-To: <20201003113050.GC18543@hjp.at>
References: <e5b66a06-8b3c-8ff7-7e23-7962026a950c@godzone.net.nz>
<20201001001100.GC26860@momjian.us>
<82097994-6772-dfd7-84e0-8f150af25e26@gmail.com>
<20201003113050.GC18543@hjp.at>
> 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. 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 mydb all reject
host mydb postgres 0.0.0.0/0 password
host mydb postgres ::0/0 password
host mydb all 0.0.0.0/0 reject
host mydb all ::0/0 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
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
“Specialising in providing low-cost professional Internet Services since
1997"
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: geustace@godzone.net.nz
Subject: Re: Restoring a database problem
In-Reply-To: <86ff9561-b8a7-501e-581e-4cecf3296b78@godzone.net.nz>
References: <e5b66a06-8b3c-8ff7-7e23-7962026a950c@godzone.net.nz> <20201001001100.GC26860@momjian.us> <82097994-6772-dfd7-84e0-8f150af25e26@gmail.com> <20201003113050.GC18543@hjp.at> <86ff9561-b8a7-501e-581e-4cecf3296b78@godzone.net.nz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox