pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: The backup API and general purpose backup software
Date: Mon, 22 Jun 2020 13:13:34 +0200
Message-ID: <20200622111334.GB5340@hjp.at> (raw)
In-Reply-To: <2b29404d-1c74-35ec-1495-5f689611e5b5@gmail.com>
References: <20200621132843.GB21591@hjp.at>
	<a48cc2eb-2407-95ef-ac56-aa26518ae4d2@gmail.com>
	<20200621154520.GC21591@hjp.at>
	<2b29404d-1c74-35ec-1495-5f689611e5b5@gmail.com>

On 2020-06-21 17:35:41 -0500, Ron wrote:
> On 6/21/20 10:45 AM, Peter J. Holzer wrote:
> > On 2020-06-21 10:32:16 -0500, Ron wrote:
> > > On 6/21/20 8:28 AM, Peter J. Holzer wrote:
> > > > To make a full backup with the "new" (non-exclusive) API, a software
> > > > must do the following
> > > > 
> > > > 1. open a connection to the database
> > > > 
> > > > 2. invoke pg_start_backup('label', false, false) in the connection from
> > > >      step 1.
> > > > 
> > > > 3. copy the contents of the data directory to the backup medium
> > > > 
> > > > 4. invoke pg_stop_backup(false, true) in the connection from step 1.
> > > > 
> > > > 5. copy the result from the previous step to the backup medium.
> > > I don't understand that last step "5. copy the result from the previous step
> > > to the backup medium."  It seems to be a duplication of "3. copy the
> > > contents of the data directory to the backup medium".
> > Step three copies all the files from the data directory. However, there
> > is an additional piece of information you you need to recover the
> > database, and that is only returned by the call to pg_stop_backup:
> > 
> > postgres=# select * from pg_stop_backup(false, true);
> > ╔═[ RECORD 1 ]═════════════════════════════════════════════════════════════════╗
[...]
> > ╚════════════╧═════════════════════════════════════════════════════════════════╝
> > 
> > Without this information the backup is useless, so it must be backed
> > up, too. Obviously you can do that only after you got it.
> 
> Thanks.  A clearer instruction for step 4, I'd have said something like
> "invoke pg_stop_backup(false, true)in the connection from step 1, piping the
> output to a file on the backup medium."

I could have phrased it that way but I wanted to set the stage for the
second half of the posting, where I was contrasting that to the work
flow of a typical general purpose backup program. 

There "piping the output to a file on the backup medium" isn't possible
because the backup is already finished. So it made sense for me to
present invoking pg_stop_backup and writing the result of pg_stop_backup
to the backup medium as two distinct steps. I think this also makes the
solution much more natural (some might even say obvious) than if those
had been presented as a single step.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (5+ messages)

Message-ID: <20200622111334.GB5340@hjp.at>
Permalink:  ../20200622111334.GB5340@hjp.at/
Also on:    postgresql.org/message-id/20200622111334.GB5340@hjp.at

 · 

reply

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: hjp-pgsql@hjp.at
  Subject: Re: The backup API and general purpose backup software
  In-Reply-To: <20200622111334.GB5340@hjp.at>
  References: <20200621132843.GB21591@hjp.at> <a48cc2eb-2407-95ef-ac56-aa26518ae4d2@gmail.com> <20200621154520.GC21591@hjp.at> <2b29404d-1c74-35ec-1495-5f689611e5b5@gmail.com> <20200622111334.GB5340@hjp.at>

* 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