Hi, thanks Steve and Chris, I have a resolution now. The cron job was running as the roger user so had the permissions. I set up the suggested logging and saw something like "unexpected EOF in tar file" (it has been overwritten now) which basically just confirmed that there was an issue with the tar file which I sort of already knew. I was able to "view" the contents of the tar file in ark and see a small listing of files, maybe the first dozen or so, none of which could be extracted.

The resolution comes as soon as I change to non-compressed tar file along the lines of:

/bin/tar -cf /media/backup/backup-home-check.tar /home/roger 2> /home/roger/admin/cron.log

and now it works. So something is broked with what ever package does the compressing - it would be interesting to figure this out, would anyone have any pointers on where to look? I will however be following the suggestion to not compress the files (as I did with work backups recently). Redirecting the errors to a file like this is extremely useful too.

Cheers,
Roger


Christopher Sawtell wrote:
Also, if your were to add   2> /some/path/to/mycronbackup.log   to the
line you'd be able to read what the error which caused the
difficulties was.

Also I'd suggest, with emphasis, that you do not compress the backup
archive, because _all_ data in the archive is lost following a
corrupted sector if you compress, but only that one corrupt sector if
you don't. Your backup data is valuable and disk space is dirt cheap
these days. The God of Backup will get you, even if Murphy and the
Devil don't. :-)



On 4/10/08, Steve Holdoway <[EMAIL PROTECTED]> wrote:
On Thu, 10 Apr 2008 21:22:29 +1200
Roger Searle <[EMAIL PROTECTED]> wrote:

Volker Kuhlmann wrote:
On Sun 06 Apr 2008 10:21:20 NZST +1200, Roger Searle wrote:


When run from the command line, they execute fine and I get the
expected
file sizes of several hundred MB or a GB.  When run from cron, they
consistently create tar files of around 5 or 10 kb.

The cause of this sort of problem is almost always the same: When you
loig in interactively, you get a fully set up login shell and
environment. When cron runs a command, it switches to the correct user
ID but barely sets up 5 environment variables. The execution environment
of your programs from within cron is different to your interactive one.

To investigate, run the command env from inside a script which is run by
cron, and redirect its output to a file. Compare with what you get
interactively. Pay special attention to PATH.

Volker

My user PATH:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
The cron environment PATH:
PATH=/usr/bin:/bin

Also:
[EMAIL PROTECTED]:~$ whereis tar
tar: /bin/tar

So tar is covered by either PATH.  However the following script will NOT
run via cron:
/bin/tar -czvf /media/backup/backup-home-`date +%a-%d-%m-%y`.tgz
/home/roger

(the tgz file is created, but is always 9 or 10kb)

Perhaps that is because the shebang at the top of the script is:
#!/bin/bash

and cron's environment has:
SHELL=/bin/sh

but changing the shebang to #!/bin/sh does not get the script running
via cron.  Can anyone suggest what I need to do?

Cheers,
Roger



Which user's crontab are you running it from, and do they have privilege to
access /home/roger. A tar tfz /media/backup... may give a bit more idea of
what's going wrong by seeing what's saved. Also, you're doing a verbose
backup. Why not save the output as a file list? It'll make it a lot easier
to see what you've saved.

Steve

--
Steve Holdoway <[EMAIL PROTECTED]>



Reply via email to