I\'m trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs:
0
A secure way of passing the password is to store it in .pgpass file
Content of the .pgpass file will be in the format:
db_host:db_port:db_name:db_user:db_pass
#Eg
localhost:5432:db1:admin:tiger
localhost:5432:db2:admin:tiger
Now, store this file in the home directory of the user with permissions u=rw (0600) or less
To find the home directory of the user, use
echo $HOME
Restrict permissions of the file
chmod 0600 /home/ubuntu/.pgpass