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
Create .pgpass file with content
host:5432:somedb:someuser:somepass
set the permissions using command
sudo chmod 600 .pgpass
Set the file owner as the same user using which you logged in :
sudo chown login_username:login_username .pgpass
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With