IMPOSSIBLE POSTGRESQL CRONTAB BACKUP ON LINUX CENTOS

Questions and answers regarding general SQL and backend databases

IMPOSSIBLE POSTGRESQL CRONTAB BACKUP ON LINUX CENTOS

Postby cuoredisardegna » Fri Dec 28, 2012 6:47 pm

Hi to All,

coul Someone resolve this problem?


1.) If on Linux Centos I execute this file:

# /usr/bin/backup.sh

wich contains

Code: Select all
#!/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
Code: Select all
* 10 * * * root /usr/bin/backup.sh


I obtain file.sql empt with zero bytes.

Tanks in advance.
Gianni Pinna.
cuoredisardegna
 
Posts: 68
Joined: Mon May 07, 2012 5:34 am

Re: IMPOSSIBLE POSTGRESQL CRONTAB BACKUP ON LINUX CENTOS

Postby ROCLASI » Fri Dec 28, 2012 7:47 pm

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: IMPOSSIBLE POSTGRESQL CRONTAB BACKUP ON LINUX CENTOS

Postby cuoredisardegna » Fri Dec 28, 2012 8:45 pm

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

Code: Select all
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.
cuoredisardegna
 
Posts: 68
Joined: Mon May 07, 2012 5:34 am

Re: RESOLVED IMPOSSIBLE POSTGRESQL CRONTAB BACKUP ON LINUXCE

Postby cuoredisardegna » Sat Dec 29, 2012 10:35 am

Tank You Robert,

1.) THE WAY
After Your message it was obtained the error message trough:
Code: Select all
command 2> file.error



2.) THE CAUSE
so, it was found the cause:
Code: Select all
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 #:
Code: Select all
#Defaults requiretty
#Defaults !visiblepw


4.) THE SOURCE
http://unix.stackexchange.com/questions/49077/why-does-cron-silently-fail-to-run-sudo-stuff-in-my-script

Tanks and Rgrds again, Robert.
Gianni Pinna
cuoredisardegna
 
Posts: 68
Joined: Mon May 07, 2012 5:34 am


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 2 guests