Discussion:
Cronjob to autobackup database
(too old to reply)
teyking2003
2012-12-04 01:13:17 UTC
Permalink
i have a cronjob setting up as below
1)Command crontab -e
2)Keyin 30 09 * * * /autopgdump.sh
3) Save to new crontab file.
but nothing happen, the backup process won't start.

i manage to perform manual backup by running the following command
sudo ./autopgdump.sh( SH file store under root directory

looking for the correct ways to setting up the cronjob.

thanks



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Krawetzky, Peter J
2012-12-04 14:35:20 UTC
Permalink
Here is a crontab example. I always specify the absolute path.

0 0 * * * /postgresql/home/scripts/backup/backup_wal_enabled_instance.sh inst1 5432


Peter Krawetzky

-----Original Message-----
From: pgsql-admin-***@postgresql.org [mailto:pgsql-admin-***@postgresql.org] On Behalf Of teyking2003
Sent: Monday, December 03, 2012 8:13 PM
To: pgsql-***@postgresql.org
Subject: [ADMIN] Cronjob to autobackup database

i have a cronjob setting up as below
1)Command crontab -e
2)Keyin 30 09 * * * /autopgdump.sh
3) Save to new crontab file.
but nothing happen, the backup process won't start.

i manage to perform manual backup by running the following command sudo ./autopgdump.sh( SH file store under root directory

looking for the correct ways to setting up the cronjob.

thanks
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
This e-mail may contain confidential or privileged information. If
you think you have received this e-mail in error, please advise the
sender by reply e-mail and then delete this e-mail immediately.
Thank you. Aetna
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
teyking2003
2012-12-05 00:48:34 UTC
Permalink
so if i putting the .SH files under root directory
the cronjob will look similar like
30 09 * * * /root/autopgdump.sh

please advice?



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735088.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
a***@gmail.com
2012-12-05 06:32:14 UTC
Permalink
Try by below method:

30 09 * * * sh /autopgdump.sh

These should work.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735118.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Spike Grobstein
2012-12-05 13:35:39 UTC
Permalink
Ahh. When you said "root" I thought you meant "/". Yes, if in /root, then /root/autopgdump.sh

You must specify absolute path in cron.



...spike
(Sent via handheld, please pardon spelling errors)
Post by teyking2003
so if i putting the .SH files under root directory
the cronjob will look similar like
30 09 * * * /root/autopgdump.sh
please advice?
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735088.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
http://www.postgresql.org/mailpref/pgsql-admin
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Spike Grobstein
2012-12-04 14:51:32 UTC
Permalink
You can debug what's going wrong with the script by adding this:

30 09 * * * /autopgdump.sh &> /autopgdump.log

that will write the output of the command to a logfile living at /autopgdump.log. If there's anything wrong with your environment (something not in the PATH of the user running the cron, etc) it should be written there. Cron runs with a slightly different environment than a regular login shell, so this can help you figure out exactly what's going wrong.

note: each time cron executes that script, it will replace the contents of /autopgdump.log; not append to it.

Also, just to double check, the above configuration would run the script at 9:30am every day, so did you wait until 9:30 for the script to run?



...spike
Post by teyking2003
i have a cronjob setting up as below
1)Command crontab -e
2)Keyin 30 09 * * * /autopgdump.sh
3) Save to new crontab file.
but nothing happen, the backup process won't start.
i manage to perform manual backup by running the following command
sudo ./autopgdump.sh( SH file store under root directory
looking for the correct ways to setting up the cronjob.
thanks
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
http://www.postgresql.org/mailpref/pgsql-admin
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
teyking2003
2012-12-06 00:39:15 UTC
Permalink
i copy this copy inside etc/cron.daily/autopgdump.sh and put in the full
directory path and wait until 930am. but nothing has been process.

do we need to setup special permission for this .SH file?



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735397.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Greg Williamson
2012-12-06 03:26:13 UTC
Permalink
A question --
________________________________
Sent: Wednesday, December 5, 2012 4:39 PM
Subject: Re: [ADMIN] Cronjob to autobackup database
i copy this copy inside etc/cron.daily/autopgdump.sh and put in the full
directory path and wait until 930am. but nothing has been process.
do we need to setup special permission for this .SH file?
If you copy the command exactly as the cron entry shows it, and, as the user who runs the cron job, paste it onto the command line and run it; what does the command do ?

If it runs from the command line, a few possibilities occur to me --

a) you didn't set the time to what you thought you did (been there, done that, easy to do).

b) Some missing part that the user's environment is providing (an ENV var, for example) but the cron job would not know about.

If it does not run from the command line, that will probably give you a clue.

HTH,

Greg Williamson
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Loading...