Re: [GENERAL] backup of postgres scheduled with cron

2007-11-22 Thread jef . peeraer


On Thu, 22 Nov 2007, Sorin N. Ciolofan wrote:

 Hello all!
 
 I've a small bash script backup.sh for creating dumps on my Postgre db:
 
   #!/bin/bash 
   time=`date '+%d'-'%m'-'%y'`
   cd /home/swkm/services/test
   pg_dump mydb  mydb_dump_$time.out
 
 I've edited crontab and added a line:
 
 00 4 * * * swkm /home/swkm/services/test/backup.sh
 
 to execute the backup.sh as user swkm daily at 4 am.
 
 The user swkm is the user I use to create backups manually. The script
 itself is executed fine if run manually but run on cron scheduler I got an
 mydb_dump_$time.out file empty (of 0 kb)
 
 Do you have any idea about what's wrong?
you have to pass the -U argument to pg_dump, otherwise it'll try to run 
the script as root


jef
 
 Thanks
 Sorin
 
 
 
 
 
 ---(end of broadcast)---
 TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
 
 

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] backup of postgres scheduled with cron

2007-11-22 Thread Frank Wittig
Hello Sorin!

Sorin N. Ciolofan wrote:

   #!/bin/bash
   time=`date '+%d'-'%m'-'%y'`
   cd /home/swkm/services/test
   pg_dump mydb  mydb_dump_$time.out

You should output STDERR to some error logfile or set MAILTO in your
crontab.
I guess you then would have seen an error message saying that pg_dump
was not found because cron doesn't load the users environment and
therefore PATH variable isn't set.
I suggest you call pg_dump in your script by absolute path.

Greetings,
Frank Wittig



signature.asc
Description: OpenPGP digital signature


Re: [GENERAL] backup of postgres scheduled with cron

2007-11-22 Thread Sorin N. Ciolofan
Thank you all,

Yes, I used the absolute path in my script and now works ok :-)

Thank you again
Sorin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Frank Wittig
Sent: Thursday, November 22, 2007 4:01 PM
To: Sorin N. Ciolofan
Cc: [EMAIL PROTECTED]; pgsql-general@postgresql.org
Subject: Re: [GENERAL] backup of postgres scheduled with cron

Hello Sorin!

Sorin N. Ciolofan wrote:

   #!/bin/bash
   time=`date '+%d'-'%m'-'%y'`
   cd /home/swkm/services/test
   pg_dump mydb  mydb_dump_$time.out

You should output STDERR to some error logfile or set MAILTO in your
crontab.
I guess you then would have seen an error message saying that pg_dump
was not found because cron doesn't load the users environment and
therefore PATH variable isn't set.
I suggest you call pg_dump in your script by absolute path.

Greetings,
Frank Wittig




---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match