pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
backup of postgres scheduled with cron
12+ messages / 6 participants
[nested] [flat]

* backup of postgres scheduled with cron
@ 2007-11-22 13:19 Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:50 ` Re: backup of postgres scheduled with cron jef.peeraer@telenet.be
  2007-11-22 14:00 ` Re: [GENERAL] backup of postgres scheduled with cron Frank Wittig <fw@weisshuhn.de>
  0 siblings, 3 replies; 12+ messages in thread

From: Sorin N. Ciolofan @ 2007-11-22 13:19 UTC (permalink / raw)
  To: pgsql-admin; +Cc: pgsql-general@postgresql.org

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?

Thanks
Sorin







^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
@ 2007-11-22 13:28 ` Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:46   ` Re: backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:53   ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
  2 siblings, 2 replies; 12+ messages in thread

From: Marco Bizzarri @ 2007-11-22 13:28 UTC (permalink / raw)
  To: Sorin N. Ciolofan <ciolofan@ics.forth.gr>; +Cc: pgsql-admin; pgsql-general@postgresql.org

On Nov 22, 2007 2:19 PM, Sorin N. Ciolofan <ciolofan@ics.forth.gr> 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?
>
> Thanks
> Sorin
>

Hi Sorin,

why don't you add a "MAILTO=<youraddress>" at the start of your
crontab file, so that you can receive a report of the problem?

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
@ 2007-11-22 13:46   ` Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:51     ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  1 sibling, 1 reply; 12+ messages in thread

From: Sorin N. Ciolofan @ 2007-11-22 13:46 UTC (permalink / raw)
  To: 'Marco Bizzarri' <marco.bizzarri@gmail.com>; +Cc: pgsql-admin; pgsql-general@postgresql.org

Hi Marco!

Thank you for the advice.

I got:

/home/swkm/services/test/backup.sh: line 4: pg_dump: command not found
updating: mydb_dump_22-11-07.out (stored 0%)

which seems strange



-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Marco Bizzarri
Sent: Thursday, November 22, 2007 3:28 PM
To: Sorin N. Ciolofan
Cc: pgsql-admin@postgresql.org; pgsql-general@postgresql.org
Subject: Re: [ADMIN] backup of postgres scheduled with cron

On Nov 22, 2007 2:19 PM, Sorin N. Ciolofan <ciolofan@ics.forth.gr> 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?
>
> Thanks
> Sorin
>

Hi Sorin,

why don't you add a "MAILTO=<youraddress>" at the start of your
crontab file, so that you can receive a report of the problem?

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:46   ` Re: backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
@ 2007-11-22 13:51     ` Marco Bizzarri <marco.bizzarri@gmail.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Marco Bizzarri @ 2007-11-22 13:51 UTC (permalink / raw)
  To: Sorin N. Ciolofan <ciolofan@ics.forth.gr>; +Cc: pgsql-admin; pgsql-general@postgresql.org

On Nov 22, 2007 2:46 PM, Sorin N. Ciolofan <ciolofan@ics.forth.gr> wrote:
> Hi Marco!
>
> Thank you for the advice.
>
> I got:
>
> /home/swkm/services/test/backup.sh: line 4: pg_dump: command not found
> updating: mydb_dump_22-11-07.out (stored 0%)
>
> which seems strange
>
>

Try putting the full path of the pg_dump command in the script.

Regards
Marco



-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
@ 2007-11-22 13:53   ` Andrew Sullivan <ajs@crankycanuck.ca>
  2007-11-22 13:59     ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 14:14     ` Re: [GENERAL] backup of postgres scheduled with cron Martin Gainty <mgainty@hotmail.com>
  1 sibling, 2 replies; 12+ messages in thread

From: Andrew Sullivan @ 2007-11-22 13:53 UTC (permalink / raw)
  To: pgsql-admin; pgsql-general@postgresql.org

On Thu, Nov 22, 2007 at 02:28:08PM +0100, Marco Bizzarri wrote:
> 
> why don't you add a "MAILTO=<youraddress>" at the start of your
> crontab file, so that you can receive a report of the problem?

Note: check that your cron accepts such an addition.  Many systems now use
Vixie's cron, which does accept that, but some don't.  It's a nice feature,
and good for this purpose.

A

-- 
Andrew Sullivan
Old sigs will return after re-constitution of blue smoke



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:53   ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
@ 2007-11-22 13:59     ` Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 14:04       ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
  1 sibling, 1 reply; 12+ messages in thread

From: Marco Bizzarri @ 2007-11-22 13:59 UTC (permalink / raw)
  To: Andrew Sullivan <ajs@crankycanuck.ca>; pgsql-admin; pgsql-general@postgresql.org

On Nov 22, 2007 2:53 PM, Andrew Sullivan <ajs@crankycanuck.ca> wrote:
> On Thu, Nov 22, 2007 at 02:28:08PM +0100, Marco Bizzarri wrote:
> >
> > why don't you add a "MAILTO=<youraddress>" at the start of your
> > crontab file, so that you can receive a report of the problem?
>
> Note: check that your cron accepts such an addition.  Many systems now use
> Vixie's cron, which does accept that, but some don't.  It's a nice feature,
> and good for this purpose.

Andrew, can you confirm the previous statement? I'm checking on a Debian Linux,
at it seems to be a Vixie Cron, and that feature is described in the man page...

>
> A
>
> --
> Andrew Sullivan
> Old sigs will return after re-constitution of blue smoke

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:53   ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
  2007-11-22 13:59     ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
@ 2007-11-22 14:04       ` Andrew Sullivan <ajs@crankycanuck.ca>
  0 siblings, 0 replies; 12+ messages in thread

From: Andrew Sullivan @ 2007-11-22 14:04 UTC (permalink / raw)
  To: Marco Bizzarri <marco.bizzarri@gmail.com>; +Cc: pgsql-admin; pgsql-general@postgresql.org

On Thu, Nov 22, 2007 at 02:59:33PM +0100, Marco Bizzarri wrote:
> Andrew, can you confirm the previous statement? I'm checking on a Debian Linux,
> at it seems to be a Vixie Cron, and that feature is described in the man page...

If the feature's in your man page, then it works on your system :)  I just
wanted to warn you that this isn't an original feature of cron, so you have
to check your system always to be sure you have it.

A

-- 
Andrew Sullivan
Old sigs will return after re-constitution of blue smoke



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: [GENERAL] backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:53   ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
@ 2007-11-22 14:14     ` Martin Gainty <mgainty@hotmail.com>
  2007-11-22 14:49       ` Re: [GENERAL] backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
  1 sibling, 1 reply; 12+ messages in thread

From: Martin Gainty @ 2007-11-22 14:14 UTC (permalink / raw)
  To: Andrew Sullivan <ajs@crankycanuck.ca>; pgsql-admin; pgsql-general@postgresql.org


Good Morning AndrewI noticed the Vixie cron responds to SIGHUP signalsDo you have any suggestions or tutorials on how Postgres would feed these event signals to Vixie cron?
Thanks/Martin ______________________________________________Disclaimer and confidentiality noteEverything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.> > On Thu, Nov 22, 2007 at 02:28:08PM +0100, Marco Bizzarri wrote:> > > > why don't you add a "MAILTO=<youraddress>" at the start of your> > crontab file, so that you can receive a report of the problem?> > Note: check that your cron accepts such an addition. Many systems now use> Vixie's cron, which does accept that, but some don't. It's a nice feature,> and good for this purpose.> > A> > -- > Andrew Sullivan> Old sigs will return after re-constitution of blue smoke> > ---------------------------(end of broadcast)---------------------------> TIP 1: if posting/reading through Usenet, please send an appropriate> subscribe-nomail command to majordomo@postgresql.org so that your> message can get through to the mailing list cleanly
_________________________________________________________________
Share life as it happens with the new Windows Live.Download today it's FREE!
http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007=

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: [GENERAL] backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 13:28 ` Re: backup of postgres scheduled with cron Marco Bizzarri <marco.bizzarri@gmail.com>
  2007-11-22 13:53   ` Re: backup of postgres scheduled with cron Andrew Sullivan <ajs@crankycanuck.ca>
  2007-11-22 14:14     ` Re: [GENERAL] backup of postgres scheduled with cron Martin Gainty <mgainty@hotmail.com>
@ 2007-11-22 14:49       ` Andrew Sullivan <ajs@crankycanuck.ca>
  0 siblings, 0 replies; 12+ messages in thread

From: Andrew Sullivan @ 2007-11-22 14:49 UTC (permalink / raw)
  To: pgsql-admin; pgsql-general@postgresql.org

On Thu, Nov 22, 2007 at 09:14:13AM -0500, Martin Gainty wrote:
> 
> Good Morning AndrewI noticed the Vixie cron responds to SIGHUP signalsDo
> you have any suggestions or tutorials on how Postgres would feed these
> event signals to Vixie cron?

Why would Postgres have to tell crond to restart? 

A

-- 
Andrew Sullivan
Old sigs will return after re-constitution of blue smoke



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
@ 2007-11-22 13:50 ` jef.peeraer@telenet.be
  2 siblings, 0 replies; 12+ messages in thread

From: jef.peeraer@telenet.be @ 2007-11-22 13:50 UTC (permalink / raw)
  To: pgsql-general@postgresql.org



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
> 
> 



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: [GENERAL] backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
@ 2007-11-22 14:00 ` Frank Wittig <fw@weisshuhn.de>
  2007-11-22 14:15   ` Re: [GENERAL] backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2 siblings, 1 reply; 12+ messages in thread

From: Frank Wittig @ 2007-11-22 14:00 UTC (permalink / raw)
  To: Sorin N. Ciolofan <ciolofan@ics.forth.gr>; +Cc: pgsql-admin; pgsql-general@postgresql.org

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

Attachments:

  signature.asc (application/pgp-signature, 250B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: [GENERAL] backup of postgres scheduled with cron
  2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  2007-11-22 14:00 ` Re: [GENERAL] backup of postgres scheduled with cron Frank Wittig <fw@weisshuhn.de>
@ 2007-11-22 14:15   ` Sorin N. Ciolofan <ciolofan@ics.forth.gr>
  0 siblings, 0 replies; 12+ messages in thread

From: Sorin N. Ciolofan @ 2007-11-22 14:15 UTC (permalink / raw)
  To: 'Frank Wittig' <fw@weisshuhn.de>; +Cc: pgsql-admin; pgsql-general@postgresql.org

Thank you all,

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

Thank you again
Sorin

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Frank Wittig
Sent: Thursday, November 22, 2007 4:01 PM
To: Sorin N. Ciolofan
Cc: pgsql-admin@postgresql.org; 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






^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2007-11-22 14:49 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-22 13:19 backup of postgres scheduled with cron Sorin N. Ciolofan <ciolofan@ics.forth.gr>
2007-11-22 13:28 ` Marco Bizzarri <marco.bizzarri@gmail.com>
2007-11-22 13:46   ` Sorin N. Ciolofan <ciolofan@ics.forth.gr>
2007-11-22 13:51     ` Marco Bizzarri <marco.bizzarri@gmail.com>
2007-11-22 13:53   ` Andrew Sullivan <ajs@crankycanuck.ca>
2007-11-22 13:59     ` Marco Bizzarri <marco.bizzarri@gmail.com>
2007-11-22 14:04       ` Andrew Sullivan <ajs@crankycanuck.ca>
2007-11-22 14:14     ` Martin Gainty <mgainty@hotmail.com>
2007-11-22 14:49       ` Andrew Sullivan <ajs@crankycanuck.ca>
2007-11-22 13:50 ` jef.peeraer@telenet.be
2007-11-22 14:00 ` Frank Wittig <fw@weisshuhn.de>
2007-11-22 14:15   ` Sorin N. Ciolofan <ciolofan@ics.forth.gr>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox