0
I have two files called lb and z-backup. z-backup is a sh script placed in cron.daily which calls the lb (sh) script as an anacron job.
These are the files and their locations:
ls -l ~/bin/lb
-rwxrwxr-x 1 chh1 chh1 1300 Oct 23 11:56 /home/chh1/bin/lb
ls -l /etc/cron.daily/z-backup
-rwxr-xr-x 1 root root 141 Oct 23 12:29 /etc/cron.daily/z-backup
The content of lb is:
#!/bin/sh
pg_dump -h localhost -p 5432 -U postgres -d crewdb -w -C -F p -b -f ~/Dropbox/postgres_backup/crewdb.backup.sql >/home/chh1/Desktop/pg_dump_log 2>&1
exit
The content of z-backup is:
#!/bin/sh
set -e
# Anacron script to run a daily backup at boot time.
exec /home/chh1/bin/lb >>/home/chh1/Desktop/anacron_log 2>&1
exit
When I run the following command I get an error message:
sudo run-parts /etc/cron.daily
run-parts: /etc/cron.daily/z-backup exited with return code 1
The anacron_log created from the z-backup script is empty:
cat ~/Desktop/anacron_log
<<there is not message>>
The pg_dump_log created from the lb script shows an error message:
cat ~/Desktop/pg_dump_log
pg_dump: [archiver (db)] connection to database "crewdb" failed: fe_sendauth: no password supplied
Other information
cat ~/.pgpass && ls -la ~/.pgpass
# hostname:port:database:username:password
*:*:crewdb:*:xDf&&li@
-rw------- 1 chh1 chh1 68 Oct 23 11:09 .pgpass
sudo cat /.pgpass && ls -la /.pgpass
# hostname:port:database:username:password
*:*:crewdb:*:xDf&&li@
-rw------- 1 root root 68 Oct 21 10:39 /.pgpass
Unix user: chh1
Database name: crewdb
Postgresql superuser: postgres
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
crewdb | postgres | UTF8 | en_NZ.UTF-8 | en_NZ.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | chh1=CTc/postgres
postgres | postgres | UTF8 | en_NZ.UTF-8 | en_NZ.UTF-8 |
template0 | postgres | UTF8 | en_NZ.UTF-8 | en_NZ.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_NZ.UTF-8 | en_NZ.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
echo "PATH=$PATH:/usr/lib/postgresql/10/bin
export PATH" >> .profile
sudo grep ^[^#] /etc/postgresql/10/main/pg_hba.conf
[sudo] password for chh1:
local all postgres md5
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
I have no clue how to resolve the error message in pg_dump_log and get the anacron job to work properly. When I run the lb script from the terminal the Postgresql backup goes ahead just fine. Does anyone have a clue why this does not work. I much appreciate your help.