From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Andrus <kobruleht2@hot.ee>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to restore to empty database
Date: Thu, 30 Jan 2020 16:22:18 -0800
Message-ID: <8ac01396-cf14-0198-c49f-5f0bd298e544@aklaver.com> (raw)
In-Reply-To: <332CC5FE386B4B86AAE5556896A635ED@dell2>
References: <D3F14323F35F4DC4BA3E517ED11199E1@dell2>
<8f1d29bd-907e-e1c5-cc5f-2b9cade5af19@aklaver.com>
<332CC5FE386B4B86AAE5556896A635ED@dell2>
On 1/30/20 3:08 PM, Andrus wrote:
> Hi!
>
>> You need to connect to a database that exists with --dbname, for
>> instance --dbname=postgres. Postgres will then use that connection to
>> create the new database, in your case mydb.
>
> Thank you, this seems work.
>
> There are total 24 databases, .backup files total size in 37GB , aprox 60 %
> from this from bytea columns ( pdf documents, images).
> Using VPS server, 4 cores, 11 GB RAM, used only for postgres.
> Which is the fastest way to restore data from all of them to empty
> databases. Should I run all commands in sequence like
These days 37 GB is relatively small, so you maybe getting into the
realm of premature optimization. Do the 24 databases represent an entire
cluster you are trying to transfer? If so have you looked at pg_dumpall?:
https://www.postgresql.org/docs/12/app-pg-dumpall.html
It is a text based backup, but it will include all the databases and the
globals.
Otherwise I think you are going to find that the below will not make
much difference given the overall size of the backup files.
>
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> --jobs=4
> "database1.backup"
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> --jobs=4
> "database2.backup"
> ...
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> --jobs=4
> "database24.backup"
>
> or run them all parallel without --jobs=4 like
>
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> "database1.backup" &
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> "database2.backup" &
> ...
> pg_restore --clean --create --if-exists --verbose --dbname=postgres
> --jobs=4
> "database24.backup" &
>
>
> or some balance between those ?
> Is there some postgres or Debian setting which can used during restore time
> to speed up restore ?
> I use shared_buffers=1GB , other settings from debian installation.
>
> Andrus.
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, kobruleht2@hot.ee
Subject: Re: How to restore to empty database
In-Reply-To: <8ac01396-cf14-0198-c49f-5f0bd298e544@aklaver.com>
References: <D3F14323F35F4DC4BA3E517ED11199E1@dell2> <8f1d29bd-907e-e1c5-cc5f-2b9cade5af19@aklaver.com> <332CC5FE386B4B86AAE5556896A635ED@dell2> <8ac01396-cf14-0198-c49f-5f0bd298e544@aklaver.com>
* 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