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@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster