Re: confusing archive_command example - Mailing list pgsql-docs

From Bruce Momjian
Subject Re: confusing archive_command example
Date
Msg-id 201003312339.o2VNdLq23837@momjian.us
Whole thread Raw
In response to confusing archive_command example  (Josh Kupershmidt <schmiddy@gmail.com>)
Responses Re: confusing archive_command example  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: confusing archive_command example  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-docs
Josh Kupershmidt wrote:
> Hi,
> On the page:
> http://www.postgresql.org/docs/current/interactive/continuous-archiving.html#BACKUP-ARCHIVING-WAL
>
> an example archive_command of:
> archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
>
> is given. Then, a few lines later, an example archive command of:
> archive_command = 'test ! -f .../%f && cp %p .../%f'
>
> is given. I think this second command would be more clear if it used
> "/mnt/server/archivedir/" instead of "...", to tie in with the
> previous archive_command. It took me a minute to figure out that the
> three dots were supposed to be an ellipsis instead of a typo for the
> parent directory "..".

I agree our use of cp -i </dev/null is a little too fancy not to be
explained in the docs, so I have done so with the attached, applied
patch.

As far as "...", those are used to show only the important changes in
the string, which I think is the right approach, but I did change the
line so the dots are not right up against slashes:

    archive_command = 'test ! -f ... %f && cp %p ... %f'

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com
Index: doc/src/sgml/backup.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/backup.sgml,v
retrieving revision 2.144
diff -c -c -r2.144 backup.sgml
*** doc/src/sgml/backup.sgml    22 Feb 2010 17:15:10 -0000    2.144
--- doc/src/sgml/backup.sgml    31 Mar 2010 23:34:20 -0000
***************
*** 604,614 ****
      directory).
      It is advisable to test your proposed archive command to ensure that it
      indeed does not overwrite an existing file, <emphasis>and that it returns
!     nonzero status in this case</>.  We have found that <literal>cp -i</> does
!     this correctly on some platforms but not others.  If the chosen command
!     does not itself handle this case correctly, you should add a command
!     to test for existence of the archive file.  For example, something
!     like:
  <programlisting>
  archive_command = 'test ! -f .../%f && cp %p .../%f'
  </programlisting>
--- 604,615 ----
      directory).
      It is advisable to test your proposed archive command to ensure that it
      indeed does not overwrite an existing file, <emphasis>and that it returns
!     nonzero status in this case</>.  On many Unix platforms, <command>cp
!     -i</> causes copy to prompt before overwriting a file, and
!     <literal>< /dev/null</> causes the prompt (and overwriting) to
!     fail.  If your platform does not support this behavior, you should
!     add a command to test for the existence of the archive file.  For
!     example, something like:
  <programlisting>
  archive_command = 'test ! -f .../%f && cp %p .../%f'
  </programlisting>

pgsql-docs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Streaming replication document improvements
Next
From: Tom Lane
Date:
Subject: Re: confusing archive_command example