Re: archive_command with an environnement variable ? - Mailing list pgsql-general

From Greg Smith
Subject Re: archive_command with an environnement variable ?
Date
Msg-id Pine.GSO.4.64.0709101541080.7565@westnet.com
Whole thread Raw
In response to archive_command with an environnement variable ?  (Eric Pailleau <eric@numlog.fr>)
List pgsql-general
On Thu, 6 Sep 2007, Eric Pailleau wrote:

> so I wonder if we can use environnement variable directly or by sourcing an
> env file, i.e :
> archive_command = 'test ! -f $myvar/%f && cp %p $myvar/%f'
> archive_command = 'csh ; source ~/.cshrc && test ! -f $myvar/%f && cp %p
> $myvar/%f'

As far as I know these won't work, because PostgreSQL doesn't substitute
environment variables before making the system call.  There might be some
way to quote things and call a shell to make it happen, but I wasn't able
to find any simple syntax I was happy with.

The whole idea of doing all the processing within the archive_command is a
bad one anyway. You should write a script that gets passed %f and %p and
let it source environment variables and do all the testing.  It can return
multiple error codes when something goes wrong and anything it writes to
standard out shows up in the server log files, all of which makes
debugging and troubleshooting much easier.

The approach of the simple example is just that--a simple example; you
shouldn't consider it a model for how you should operate.  Having the code
in an external script gives you considerably more flexibility than trying
to squeeze everything into the archive_command.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-general by date:

Previous
From: novnov
Date:
Subject: Re: Time Zone design issues
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Time Zone design issues