If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Impossible postgresql crontab backup on linux centos

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Dec 2012
Posts: 30
Impossible postgresql crontab backup on linux centos

Hi to All,

coul Someone resolve this problem?


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

Code:
# /usr/bin/backup.sh
wich contains

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


I obtain file.sql empty with zero bytes.

Tanks in advance.
Gianni Pinna.

Last edited by Pat Phelan; 12-28-12 at 16:35. Reason: Replaced manged QUOTE markers with working CODE markers
Reply With Quote
  #2 (permalink)  
Old
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 14,791
  1. Is the crontab file owner the same login that you used to launch the backup.sh file from 1) above?
  2. Is the /etc/passwd file set correctly for the owner of the crontab file?
  3. If in doubt, consult CentOS 5.5 - crontab(5)
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old
Programming since 1BC
 
Join Date: Sep 2009
Location: Ontario
Posts: 982
Your crontab entry should not contain the word "root".
The format is the 5 frequency fields followed by the command, the user/owner field that you have entered is not required.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Dec 2012
Posts: 30
[resolved]

Hi to All,

many tanks to -PatP and to Kitaman for the Kind answer.

THE SOLUTION :It was necessary to type the entire path:

/opt/PostgreSQL/8.4/bin/pg_dump etc.

Without it the postgres command was not found.

Abou, root not required, Kitaman, it is working well, also if I'll try without it.

Best Rgrds.
Gianni Pinna.
Reply With Quote
  #5 (permalink)  
Old
Programming since 1BC
 
Join Date: Sep 2009
Location: Ontario
Posts: 982
When you are developing a new cron script, it is helpful to add the following line at/near the beginning.
Code:
env >/tmp/mycronscript.log
You can then compare that output with the environment in a terminal session.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On