Обсуждение: pg_dump from crontab

Поиск
Список
Период
Сортировка

pg_dump from crontab

От
"Nirav Parikh"
Дата:
Hi,
 
I am having problem backing up database from crontab, I got following lines in crontab file
 
 
0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database > /usr/backup/friDATE4.pgdump
0 20 * * 4 pg_dump -F c database > /usr/backup/thurDATE06-3.pgdump
 
none of them works, I have given full permission to everyone in /usr/backup directory
 
it creates the dump file but with 0 size - empty!
 
I have other commands in crontab which executes normally, also pg_dump command works through command line.
 
does anyone what else I can check?
 
 
 

Regards,

 

 

Nirav

Re: pg_dump from crontab

От
Ivo Rossacher
Дата:
Am Freitag, 4. August 2006 09.20 schrieb Nirav Parikh:
> Hi,
>
> I am having problem backing up database from crontab, I got following
> lines in crontab file
>
>
> 0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database >
> /usr/backup/friDATE4.pgdump
> 0 20 * * 4 pg_dump -F c database > /usr/backup/thurDATE06-3.pgdump
>
> none of them works, I have given full permission to everyone in
> /usr/backup directory
>
> it creates the dump file but with 0 size - empty!
>
> I have other commands in crontab which executes normally, also pg_dump
> command works through command line.
>
> does anyone what else I can check?

Probably the permission at the database which the user has that owns the
crontab file?
Does the command work in a shell of this user?

Best regards
Ivo
>
>
>
>
> Regards,
>
>
>
>
>
> Nirav

Re: pg_dump from crontab

От
Scott Marlowe
Дата:
On Fri, 2006-08-04 at 02:20, Nirav Parikh wrote:
> Hi,
>
> I am having problem backing up database from crontab, I got following
> lines in crontab file
>
>
> 0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database >
> /usr/backup/friDATE4.pgdump
> 0 20 * * 4 pg_dump -F c database > /usr/backup/thurDATE06-3.pgdump
>
> none of them works, I have given full permission to everyone in
> /usr/backup directory
>
> it creates the dump file but with 0 size - empty!
>
> I have other commands in crontab which executes normally, also pg_dump
> command works through command line.
>
> does anyone what else I can check?

Often, I need to add the path to the pg_dump files, and I also set my
shell and home directory in my crontab.  Don't know if it'll help, but
it won't hurt.

PATH=/usr/local/pgsql/bin:/bin:/usr/bin
SHELL=/bin/bash
HOME=/home/smarlowe

Then I set my passwords in the ~/.pgpass file so that the various psql
scripts can log in.

Re: pg_dump from crontab

От
Steve Crawford
Дата:
Nirav Parikh wrote:
> Hi,
>
> I am having problem backing up database from crontab, I got following
> lines in crontab file
>
>
> 0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database >
> /usr/backup/friDATE4.pgdump
> 0 20 * * 4 pg_dump -F c database > /usr/backup/thurDATE06-3.pgdump
>
> none of them works, I have given full permission to everyone in
> /usr/backup directory
>
> it creates the dump file but with 0 size - empty!
>
> I have other commands in crontab which executes normally, also pg_dump
> command works through command line.
>
> does anyone what else I can check?

Is the cron backup process running as the same user as your command-line
version? I am, of course, assuming as well that the command-line success
is on the same machine as the crontab.

Are your startup scripts setting any environment variables that may not
be set when cron runs the job?

Is there anything interesting in the PostgreSQL server log at the time
of your backup attempt?

Does a simple command in crontab succeed in writing to the same
directory (something like * * * * * date >> /usr/backup/crondatetest)?

Try redirecting stderr (add something like 2> ~/pg_dump.err to your
crontab command) and see if any errors are being generated. (Most cron
implementations will send an email if anything is output to stderr or
stdout but this assumes that the crontab user's email is actually routed
to someplace that it will end up being seen.)

Cheers,
Steve

Re: pg_dump from crontab

От
Adam Radlowski
Дата:
Try (do not use ">" output stream redirection, but "-f" switch):
0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database -f
/usr/backup/friDATE4.pgdump
0 20 * * 4 pg_dump -F c database -f /usr/backup/thurDATE06-3.pgdump
Or instead (if it will not work):
1. Put those commands into root crontab file (/var/spool/cron/root)
2. Instead raw putting the commands into crontab file, put them into
scripts and run for them the shell - for example:
0 20 * * 5 /bin/sh /home/scripts/fri_date4.sh
0 20 * * 4 /bin/sh /home/scripts//thur_date06-3.sh

Into /home/scripts/fri_date4.sh You put line:
/usr/pgsql/bin/pg_dump -F c database -f /usr/backup/friDATE4.pgdump
Into /home/scripts//thur_date06-3.sh You put line:
pg_dump -F c database -f /usr/backup/thurDATE06-3.pgdump

Greetings
Adam

Nirav Parikh wrote:

> Hi,
>
> I am having problem backing up database from crontab, I got following
> lines in crontab file
>
>
> 0 20 * * 5 /usr/pgsql/bin/pg_dump -F c database >
> /usr/backup/friDATE4.pgdump
> 0 20 * * 4 pg_dump -F c database > /usr/backup/thurDATE06-3.pgdump
>
> none of them works, I have given full permission to everyone in
> /usr/backup directory
>
> it creates the dump file but with 0 size - empty!
>
> I have other commands in crontab which executes normally, also pg_dump
> command works through command line.
>
> does anyone what else I can check?
>
>
>
>
> Regards*, *
>
> * *
>
> * *
>
> *Nirav*
>