Re: archive_command with an environnement variable ?

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Eric Pailleau <eric(at)numlog(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: archive_command with an environnement variable ?
Date: 2007-09-10 19:53:47
Message-ID: Pine.GSO.4.64.0709101541080.7565@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-09-10 20:12:26 Re: Time Zone design issues
Previous Message novnov 2007-09-10 19:44:04 Re: Time Zone design issues