pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
archive_commnad parameter question
5+ messages / 5 participants
[nested] [flat]

* archive_commnad parameter question
@ 2021-04-19 21:09  Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
  0 siblings, 4 replies; 5+ messages in thread

From: Allie Crawford @ 2021-04-19 21:09 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hello,
I am new in PostgreSQL and I am trying to understand what the “test” word is representing in the archive_command configuration that the PostgreSQL documentation is showing as the format on how to set up this parameter

archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'  # Unix

Does anybody know what is “test” representing in this parameter configuration?

Thank in advance for your help on this.

Regards,
Allie

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: archive_commnad parameter question
@ 2021-04-19 21:16  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
  3 siblings, 0 replies; 5+ messages in thread

From: Adrian Klaver @ 2021-04-19 21:16 UTC (permalink / raw)
  To: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 4/19/21 2:09 PM, Allie Crawford wrote:
> Hello,
> 
> I am new in PostgreSQL and I am trying to understand what the “test” 
> word is representing in the archive_command configuration that the 
> PostgreSQL documentation is showing as the format on how to set up this 
> parameter
> 
> archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p 
> /mnt/server/archivedir/%f'  # Unix
> 
> Does anybody know what is “test” representing in this parameter 
> configuration?

Per the docs:

"This is an example, not a recommendation, and might not work on all 
platforms."

test in this case refers to a shell command:

https://www.computerhope.com/unix/bash/test.htm

So this only works in environments that have that command.

> 
> Thank in advance for your help on this.
> 
> Regards,
> 
> Allie
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: archive_commnad parameter question
@ 2021-04-19 21:16  Gavan Schneider <list.pg.gavan@pendari.org>
  parent: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
  3 siblings, 0 replies; 5+ messages in thread

From: Gavan Schneider @ 2021-04-19 21:16 UTC (permalink / raw)
  To: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>; +Cc: pgsql-general@lists.postgresql.org

On 20 Apr 2021, at 7:09, Allie Crawford wrote:

> archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p 
> /mnt/server/archivedir/%f'  # Unix
>
> Does anybody know what is “test” representing in this parameter 
> configuration?
>
my_unix_prompt> man test

gives:
	 Tests  the  expression given and sets the exit status to 0 if true, 
and 1 if false. An expression is made up
	  of one or more operators and their arguments.

In other words “test” here is a unix command which evaluated the 
expression supplied via the arguments.
Mostly used in its alternate form of “[ … ]” in shell scripts

Gavan Schneider
——
Gavan Schneider, Sodwalls, NSW, Australia
Explanations exist; they have existed for all time; there is always a 
well-known solution to every human problem — neat, plausible, and 
wrong.
— H. L. Mencken, 1920





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: archive_commnad parameter question
@ 2021-04-19 21:18  Peter J. Holzer <hjp-pgsql@hjp.at>
  parent: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
  3 siblings, 0 replies; 5+ messages in thread

From: Peter J. Holzer @ 2021-04-19 21:18 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 2021-04-19 21:09:13 +0000, Allie Crawford wrote:
> I am new in PostgreSQL and I am trying to understand what the “test” word is
> representing in the archive_command configuration that the PostgreSQL
> documentation is showing as the format on how to set up this parameter
> 
> archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/
> archivedir/%f'  # Unix
> 
> Does anybody know what is “test” representing in this parameter configuration?

"test" is a unix command for testing stuff (as the name implies).
"test -f" in particular tests whether the argument exists and is a
regular file) and the "!" inverts the result.

So the whole line checks that the target *doesn't* already exist before
attempting to copy over it.

        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

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: archive_commnad parameter question
@ 2021-04-19 21:19  Alan Hodgson <ahodgson@lists.simkin.ca>
  parent: Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
  3 siblings, 0 replies; 5+ messages in thread

From: Alan Hodgson @ 2021-04-19 21:19 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On Mon, 2021-04-19 at 21:09 +0000, Allie Crawford wrote:
> Hello,
> I am new in PostgreSQL and I am trying to understand what the “test” word is
> representing in the archive_command configuration that the PostgreSQL
> documentation is showing as the format on how to set up this parameter
>  
> archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p
> /mnt/server/archivedir/%f'  # Unix
>  
> Does anybody know what is “test” representing in this parameter
> configuration?

'test' in this case is an actual executable present on many Unix and Unix-like
systems.

In this case it effectively gates the copy (cp) command so that it only runs
if the target file does not already exist. 

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-04-19 21:19 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 21:09 archive_commnad parameter question Allie Crawford <CrawfordMA@ChurchofJesusChrist.org>
2021-04-19 21:16 ` Adrian Klaver <adrian.klaver@aklaver.com>
2021-04-19 21:16 ` Gavan Schneider <list.pg.gavan@pendari.org>
2021-04-19 21:18 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2021-04-19 21:19 ` Alan Hodgson <ahodgson@lists.simkin.ca>

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