confusing archive_command example

Поиск
Список
Период
Сортировка
Искать

confusing archive_command example

От:
Josh Kupershmidt <schmiddy@gmail.com>
Дата:
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 

Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
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  
> 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         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, and that it returns
!     nonzero status in this case</>.  We have found that 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:
  
  archive_command = 'test ! -f .../%f && cp %p .../%f'
  
--- 604,615 ----
      directory).
      It is advisable to test your proposed archive command to ensure that it
      indeed does not overwrite an existing file, and that it returns
!     nonzero status in this case</>.  On many Unix platforms, cp
!     -i</> causes copy to prompt before overwriting a file, and
!     < /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:
  
  archive_command = 'test ! -f .../%f && cp %p .../%f'
  

Re: confusing archive_command example

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> 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'

This is *not* an improvement, because it makes it look like the %f is a
separate command argument.  Please revert if you can't think of
something better.

			regards, tom lane

Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote:
> Bruce Momjian  writes:
> > 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'
> 
> This is *not* an improvement, because it makes it look like the %f is a
> separate command argument.  Please revert if you can't think of
> something better.

What about:

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

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

Re: confusing archive_command example

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> What about:
>  	archive_command = 'test ! -f ...%f && cp %p ...%f'

Perhaps, though I still think this isn't an improvement over the
original.

			regards, tom lane

Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote:
> Bruce Momjian  writes:
> > What about:
> >  	archive_command = 'test ! -f ...%f && cp %p ...%f'
> 
> Perhaps, though I still think this isn't an improvement over the
> original.

His complaint was that .../%f looks like ../%f;  is that a valid
concern?  I have reverted the change.  Also, should we be using test !
-e instead of -f?

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

Re: confusing archive_command example

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> His complaint was that .../%f looks like ../%f;  is that a valid
> concern?

Well, it does look like it, I'm just not seeing an easy fix that makes
that better.  I think the original suggestion was to turn it into a
concrete example by writing something like /mnt/archive/%f.

> I have reverted the change.  Also, should we be using test !
> -e instead of -f?

No opinion.

			regards, tom lane

Re: confusing archive_command example

От:
"Greg Sabino Mullane" <greg@turnstep.com>
Дата:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> 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'

The triple dots need to be removed entirely, too confusing. Write 
everything out.

- -- 
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201003312007
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkuz5AwACgkQvJuQZxSWSshGMACdEBRm5VScsv4w2fGTZTTr3b19
Zj8AoIFV9exrwQfO8t8MSwL0BXx41ZCU
=VP+w
-----END PGP SIGNATURE-----


Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote:
> Bruce Momjian  writes:
> > His complaint was that .../%f looks like ../%f;  is that a valid
> > concern?
> 
> Well, it does look like it, I'm just not seeing an easy fix that makes
> that better.  I think the original suggestion was to turn it into a
> concrete example by writing something like /mnt/archive/%f.
> 
> > I have reverted the change.  Also, should we be using test !
> > -e instead of -f?
> 
> No opinion.

Well -e tests for any type of file, while -f is only for regular files. 
In practice, there should only be regular files in the archive
directory.  But because we are always super-cautious, I changed it to
-e.

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

Re: confusing archive_command example

От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
On ons, 2010-03-31 at 19:51 -0400, Bruce Momjian wrote:
> Also, should we be using test ! -e instead of -f? 

test -e is not portable.

Re: confusing archive_command example

От:
Greg Smith <greg@2ndquadrant.com>
Дата:
Peter Eisentraut wrote:
> On ons, 2010-03-31 at 19:51 -0400, Bruce Momjian wrote:
>   
>> Also, should we be using test ! -e instead of -f? 
>>     
>
> test -e is not portable.
>   

Right; there are plenty of shells where "test -e" isn't implemented, I 
believe some Solaris and/or HP-UX systems have that issue.  The original 
"test -f" was already the best example to give here.

As for the update Josh suggested, there are two issues here.  The PITR 
documentation at 
http://developer.postgresql.org/pgdocs/postgres/continuous-archiving.html 
starts with this example:

archive_command = 'cp -i %p /mnt/server/archivedir/%f 

Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Peter Eisentraut wrote:
> On ons, 2010-03-31 at 19:51 -0400, Bruce Momjian wrote:
> > Also, should we be using test ! -e instead of -f? 
> 
> test -e is not portable.

Thanks, reverted

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

Re: confusing archive_command example

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Greg Smith wrote:
> The third issue here, not mentioned yet, is that there's also an example 
> of setting up archive_command in its GUC documentation:
> 
> http://developer.postgresql.org/pgdocs/postgres/runtime-config-wal.html
> 
> This has drifted out of sync with the section being updated here this 
> week--its archive_command example isn't even using "-i".  I think the 
> right thing to do here is to migrate the Windows example out of 18.5.3 
> from 24.3.1, then replace the existing examples in 18.5.3 to instead 
> suggest 24.3.1 has them.  Given that all of this documentation giving 
> examples for how to correctly configure that parameter, like this cp 
> trivia, only appears in the PITR docs section, I don't see any reason to 
> duplicate that in the GUC area.  Having the second, minimally documented 
> version of those in 18.5.3 just encourages people to use what we know is 
> a bad practice by providing them as examples.

Agreed.  The attached applied patch removes the example from the
configure section.

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com
Index: doc/src/sgml/config.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/config.sgml,v
retrieving revision 1.262
diff -c -c -r1.262 config.sgml
*** doc/src/sgml/config.sgml	3 Apr 2010 07:22:53 -0000	1.262
--- doc/src/sgml/config.sgml	12 Apr 2010 21:59:26 -0000
***************
*** 1721,1728 ****
          (The path name is relative to the working directory of the server,
          i.e., the cluster's data directory.)
          Use %%</> to embed an actual %</> character in the
!         command. For more information see .
          This parameter can only be set in the postgresql.conf</>
          file or on the server command line.  It is ignored unless
          archive_mode</> was enabled at server start.
--- 1721,1731 ----
          (The path name is relative to the working directory of the server,
          i.e., the cluster's data directory.)
          Use %%</> to embed an actual %</> character in the
!         command.  It is important for the command to return a zero
!         exit status only if it succeeds. For more information see
!         .
!        
!        
          This parameter can only be set in the postgresql.conf</>
          file or on the server command line.  It is ignored unless
          archive_mode</> was enabled at server start.
***************
*** 1735,1748 ****
          archiving, but also breaks the chain of WAL files needed for
          archive recovery, so it should only be used in unusual circumstances.
         
-        
-         It is important for the command to return a zero exit status if
-         and only if it succeeds.  Examples:
- 
- archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
- archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"'  # Windows
- 
-        
        
       
       
--- 1738,1743 ----
FAQ