Question: I am using `areca` backup program and I wrote a script in it to backup postgre database.
I want to get password via `pgpass.conf` file but I can't give it's path to script.
How can I use `PGPASSFILE` ?
This is my script (; is separator) :

```
-U;postgres;-w;-F;custom;-b;-f;D:\satraAutoBackup\Daily\Saturday\postgresql\geoMolkBackup;geoMolkPortal2

```

Answer: 
1. Create .pgpass file with content 

> 
> host:5432:somedb:someuser:somepass
> 
> 
>
2. set the permissions using command 

> 
> sudo chmod 600 .pgpass
> 
> 
>
3. Set the file owner as the same user using which you logged in :

> 
> sudo chown login\_username:login\_username .pgpass
> 
> 
>
4. Set PGPASSFILE environment variable :

> 
> export PGPASSFILE='/home/user/.pgpass'
> 
> 
>

Now check by connecting to database (remove -w) : 

> 
> psql -h host -U someuser somedb
> 
> 
> 

It will not prompt for password and logged in to postgresql.
You can do that by setting the environment variable `PGPASSFILE` to the path of `pgpass.conf` and by removing the `-w` parameter.  

eg.:`export PGPASSFILE="/path/to/pgpass.conf"`

PS: Make sure to set the `pgpass.conf` in a secure place and locking it using NTFS permission for example.

A use case here on this [wiki page](https://wiki.postgresql.org/wiki/Automated_Backup_on_Windows)