| From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> | 
|---|---|
| To: | pgsql-admin(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: Automating pg_Dump on Windows 2016 Server | 
| Date: | 2018-11-14 21:59:17 | 
| Message-ID: | d1587115-7566-aad6-050d-50671ed018e7@gmx.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-admin | 
Simon White schrieb am 14.11.2018 um 20:49:
> Automating pg_dump seems to be unnecessarily difficult from Windows
> Server 2016.  I have tried using the PGPASSWORD environment variable
> and the PGPASSFILE environment variable all to no avail.  The result
> is that I am always prompted for a password.  Could you not create a
> option to pass the password on the command line or the location of a
> password file to be used. That certainly would make things simpler.
> 
> Since I was using the "postgres" user I tried setting the password
> under the "postgres" user in pgAdmin4 but that did not help either.
> 
I have no problems setting the variable inside a batch file:
   setlocal
   set PGPASSWORD=verysecret
   pg_dump -U myuser -D ....
By default Postgres uses the "Local System" account to run the service. I don't think that is a Windows user for which you can define environment variables. So you would need to define the environment variable as a global one.
If you don't want to use a batch file, you could create a dedicated Windows user where you set the environment variables and then use that user to run the service. But make sure you adjust the privilege on the data directory. Using a batch file for pg_dump is most probably a lot easier.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Zhidenkov | 2018-11-15 03:22:25 | Re: hot_standby_feedback parameter doesn't work | 
| Previous Message | Simon White | 2018-11-14 19:49:18 | Automating pg_Dump on Windows 2016 Server |