November 30th, 2013, 05:31 PM
Use environment variables in postgresql.conf
Is it possible to use environment variables in postgresql.conf and perhaps related configuration files?
For example, I would like to use an env variable to specify the data directory.
December 1st, 2013, 12:36 PM
I've never seen that, but I'd also advise against it because it makes your database depend on wether you remembered to setup your ENV variables properly. If you lose that var, for whatever reason, you cannot start the database. Murphy says that will happen at the most annoying moment you can imagine.
*if* you want to switch the data directory around, why not specify it in the startup script? Then you can use an ENV in the command that starts the database and you'd basically have what you want (with the same reasons why you probably shouldn't do that either)
December 1st, 2013, 01:30 PM
You can do it the other way round: Postgres will take the value of the environment variable DATADIR
Originally Posted by imagenesis
Taken from: http://www.postgresql.org/docs/current/static/app-pg-ctl.html
Originally Posted by The Manual
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions: