how to create ambari database backup without enter password We configure the file .pgpass as follows in order to create database backups without entering a password:

-bash-4.2$ more .pgpass
localhost:5432:postgres:ambari:bigdata
-bash-4.2$ pwd
/var/lib/pgsql
-bash-4.2$ whoami
postgres
-bash-4.2$ more .pgpass
localhost:5432:postgres:ambari:bigdata
-bash-4.2$


But after that still pg_dump insists to enter the password - why?

Where am I wrong?

pg_dump -U  ambari  -f ambari.sql
Password:
You are trying to connect to a database called ambari this way (when specifying only the -U parameter, the DB name is taken from its value).  

From the .pgpass file it looks you want to connect to the postgres DB.  Specify -d postgres, too, or set

localhost:5432:*:ambari:bigdata


in your .pgpass file.  (As it turns out, there is an ambari DB, so the connection parameters look all right.)

Note that by default this file has to be in the OS user's (in this case postgres) home directory.  Alternatively, you can specify its location in other ways.