Re: Possible mistake in backup documentation

2020-09-25 Thread Laurenz Albe
On Tue, 2020-09-22 at 14:17 +, PG Doc comments form wrote:
> In "25.3.3.2. Making An Exclusive Low-Level Backup", you said that "The
> exclusive backup method is deprecated and should be avoided. Prior to
> PostgreSQL 9.6, this was the only low-level method available, but it is now
> recommended that all users upgrade their scripts to use non-exclusive
> backups". But in the example in "25.3.6.1. Standalone Hot Backups" you use
> the exclusive version of backup command. Is it a mistake or not?

Yes, that's true.

How about the attached patch?

Perhaps that is too complicated, but I have no idea how to make it simpler.
Ceterum censeo, we should not deprecate the exclusive backup API.

Yours,
Laurenz Albe
From 283fa644c15b08894fdff957e57e526b85913951 Mon Sep 17 00:00:00 2001
From: Laurenz Albe 
Date: Fri, 25 Sep 2020 14:26:58 +0200
Subject: [PATCH] Use non-exclusive backup in example

Since we habe deprecated the exclusive backup API, we should not
use it in examples.

Discussion: https://postgr.es/m/160078426053.14061.808669930112439...@wrigleys.postgresql.org
---
 doc/src/sgml/backup.sgml | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index b9331830f7..ddf2aa3f35 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -1496,15 +1496,19 @@ archive_command = 'test ! -f /var/lib/pgsql/backup_in_progress || (test ! -f /va
   following:
 
 touch /var/lib/pgsql/backup_in_progress
-psql -c "select pg_start_backup('hot_backup');"
-tar -cf /var/lib/pgsql/backup.tar /var/lib/pgsql/data/
-psql -c "select pg_stop_backup();"
-rm /var/lib/pgsql/backup_in_progress
-tar -rf /var/lib/pgsql/backup.tar /var/lib/pgsql/archive/
+mkdir /tmp/data
+psql -Atq -c "select pg_start_backup(label => 'hot_backup', exclusive => FALSE);" \
+  -c "\! tar -cf /var/lib/pgsql/backup.tar -C /var/lib/pgsql/ data/" \
+  -c "\o /tmp/data/backup_label" \
+  -c "SELECT labelfile FROM pg_stop_backup(exclusive => FALSE);"
+tar -rf /var/lib/pgsql/backup.tar -C /tmp data/backup_label
+rm -r /var/lib/pgsql/backup_in_progress /tmp/data
+tar -rf /var/lib/pgsql/backup.tar -C /var/lib/pgsql/ archive/
 
   The switch file /var/lib/pgsql/backup_in_progress is
   created first, enabling archiving of completed WAL files to occur.
-  After the backup the switch file is removed. Archived WAL files are
+  After the backup the switch file is removed. backup_label
+  and archived WAL files are
   then added to the backup so that both base backup and all required
   WAL files are part of the same tar file.
   Please remember to add error handling to your backup scripts.
-- 
2.26.2



Re: Possible mistake in backup documentation

2020-09-25 Thread Magnus Hagander
On Fri, Sep 25, 2020 at 2:32 PM Laurenz Albe 
wrote:

> On Tue, 2020-09-22 at 14:17 +, PG Doc comments form wrote:
> > In "25.3.3.2. Making An Exclusive Low-Level Backup", you said that "The
> > exclusive backup method is deprecated and should be avoided. Prior to
> > PostgreSQL 9.6, this was the only low-level method available, but it is
> now
> > recommended that all users upgrade their scripts to use non-exclusive
> > backups". But in the example in "25.3.6.1. Standalone Hot Backups" you
> use
> > the exclusive version of backup command. Is it a mistake or not?
>
> Yes, that's true.
>

Well, technically it is *correct*. It's just rather silly that we are using
the deprecated API in the example.


How about the attached patch?
>

> Perhaps that is too complicated, but I have no idea how to make it simpler.
>

For this example, can't we just show two sessions. That is, "in a psql, run
pg_start_backup(). Then in a different session, copy all the files, and
then back in psql run pg_stop_backup()" or such?

This is still just an example of a low level operation, where the
recommendation is (and is there iirc) to use a different tool for it
already.



> Ceterum censeo, we should not deprecate the exclusive backup API.
>

Well. We should depreciate the way it works now, but we should also provide
a *better* way to solve the actual problem. This is not necessarily an API
that looks the way the deprecated one looks -- the focus should be on
providing a solution to the problem, not to un-deprecate the API.

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ 
 Work: https://www.redpill-linpro.com/