Talk:Automated Backup on Linux

From PostgreSQL wiki

Revision as of 07:56, 1 July 2014 by Adrianlzt (Talk | contribs)

Jump to: navigation, search

Hi Guys,

This works well but i have to manually type in the password to access database.

If i need to automate this , i need to have the password read automatically.

Please assist on how to do this.


With the default installation postgres user is allowed to access but via socket no via localhost. A quick fix is to remove


from the psql commands.


In the script it didn't check if the config file exists:

if [ $# = 0 ]; then
       SCRIPTPATH=$(cd ${0%/*} && pwd -P)
       source $SCRIPTPATH/pg_backup.config

Without the config file it will not make any backup because this will be empty or false:

if [ $ENABLE_PLAIN_BACKUPS = "yes" ]

I think that piece of code should be changed to be like the script:

if [ -z $CONFIG_FILE_PATH ] ; then
       SCRIPTPATH=$(cd ${0%/*} && pwd -P)

if [ ! -r ${CONFIG_FILE_PATH} ] ; then
       echo "Could not load config file from ${CONFIG_FILE_PATH}" 1>&2
       exit 1

source "${CONFIG_FILE_PATH}"


With Bash 4.1.2: /usr/local/sbin/ line 37: [: too many arguments

Line 37 should be changed to:

if  $BACKUP_USER != "" && "$(id -un)" != "$BACKUP_USER"  ; then
Personal tools