PGPASSWORD - More than one in a bash script

Started by Patrick Bover 9 years ago3 messagesgeneral
Jump to latest
#1Patrick B
patrickbakerbr@gmail.com

Hi guys,

I'm writing a bash script to dump and restore (pg_dump + pg_restore) a test
database.

However, the username to access the pg_dump server is different of the one
to access pg_restore.

I'm using the PGPASSWORD parameter on the script, but can I put two of that?

like:

PGPASSWORD
PGPASSWORD2

If not, do you guys have any idea how I could do this?

I'm using PostgreSQL 9.5

cheers

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Patrick B (#1)
Re: PGPASSWORD - More than one in a bash script

On 08/17/2016 09:01 PM, Patrick B wrote:

Hi guys,

I'm writing a bash script to dump and restore (pg_dump + pg_restore) a
test database.

However, the username to access the pg_dump server is different of the
one to access pg_restore.

I'm using the PGPASSWORD parameter on the script, but can I put two of that?

like:

PGPASSWORD
PGPASSWORD2

If not, do you guys have any idea how I could do this?

https://www.postgresql.org/docs/9.5/static/libpq-pgpass.html

I'm using PostgreSQL 9.5

cheers

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Patrick B (#1)
Re: PGPASSWORD - More than one in a bash script

On Thursday, August 18, 2016, Patrick B <patrickbakerbr@gmail.com> wrote:

Hi guys,

I'm writing a bash script to dump and restore (pg_dump + pg_restore) a
test database.

However, the username to access the pg_dump server is different of the one
to access pg_restore.

I'm using the PGPASSWORD parameter on the script, but can I put two of
that?

like:

PGPASSWORD
PGPASSWORD2

If not, do you guys have any idea how I could do this?

I'm using PostgreSQL 9.5

You cannot. Instead, create your own variables and then, in the script,
assign their values to pgpassword when appropriate.

David J.