Hi to All,
coul Someone resolve this problem?
1.) If on Linux Centos I execute this file:
/usr/bin/backup.sh
wich contains
#!/bin/bash
export PGPASSWORD=”mia_password_del_db” && pg_dump -h localhost -U user -c -R -v nome_database -n nome_schema > /percorso/dove/salvare/il/file.sql
I obtain a perfect backup in file.sql
2.) But if I put in crontab
* 10 * * * root /usr/bin/backup.sh
I obtain file.sql empt with zero bytes.
Tanks in advance.
Gianni Pinna.
ROCLASI
December 28, 2012, 5:47pm
2
Hi Gianni,
Do you see anything in the system log files ?
Also it’s not recommended to use a environment variable to pass the password. It’s not secure.
It’s recommended to use a pgpass file, see http://www.postgresql.org/docs/9.2/stat … gpass.html for more information.
Hi Robert,
I read You with much pleasure. Hope fine of You and Your Christmas.
Tank You for Your Prompt replay.
Here it is The log message
Dec 28 17:43:01 localhost crond[4120]: (root) CMD (export PGPASSWORD='PASSWD' && pg_dump -h root -U postgres -c -R -v AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE > /root/backups/AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE.sql)
I am going to see the link.
Hope to read You again.
Many Tanks, Robert.
Gianni Pinna.
Tank You Robert,
1.) THE WAY
After Your message it was obtained the error message trough:
command 2> file.error
2.) THE CAUSE
so, it was found the cause:
sudo: Sorry, you must have a tty to run sudo
3.) THE REMEDY
In the file /etc/sudoers the following lines were switched to off trough #:
#Defaults requiretty
#Defaults !visiblepw
4.) THE SOURCE
sudo, cron
Tanks and Rgrds again, Robert.
Gianni Pinna