Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gN3C3-0001Vk-8e for pgsql-admin@arkaria.postgresql.org; Wed, 14 Nov 2018 21:59:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gN3C1-0001ZC-58 for pgsql-admin@arkaria.postgresql.org; Wed, 14 Nov 2018 21:59:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gN3C0-0001Yd-N5 for pgsql-admin@lists.postgresql.org; Wed, 14 Nov 2018 21:59:24 +0000 Received: from mail-out.m-online.net ([212.18.0.10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gN3Bx-0007AY-L9 for pgsql-admin@lists.postgresql.org; Wed, 14 Nov 2018 21:59:23 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42wJLH09Bpz1r3bG for ; Wed, 14 Nov 2018 22:59:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42wJLG4mqrz1qsJZ for ; Wed, 14 Nov 2018 22:59:18 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id X5C86PjTT-A7 for ; Wed, 14 Nov 2018 22:59:18 +0100 (CET) Received: from [192.168.178.37] (ppp-93-104-73-245.dynamic.mnet-online.de [93.104.73.245]) by mail.mnet-online.de (Postfix) with ESMTP for ; Wed, 14 Nov 2018 22:59:18 +0100 (CET) Subject: Re: Automating pg_Dump on Windows 2016 Server To: pgsql-admin@lists.postgresql.org Newsgroups: gmane.comp.db.postgresql.admin References: From: Thomas Kellerer Message-ID: Date: Wed, 14 Nov 2018 22:59:17 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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.