Problem With Script in cron.daily
I found this script, modified it, got it working like I wanted and put it in cron.daily. Problem is, it keeps emailing me messages. This is what it mails
/bin/tar: Removing leading `/' from member names /dev/sda on /mnt type vfat (rw) How do I suppress these messages? I don't see any quiet options. Maybe it would be better if I ran it from root's crontab? Here is the script. #!/bin/sh # full and incremental backup script # created 07 February 2000 # Based on a script by Daniel O'Callaghan <danny@freebsd.org> # and modified by Gerhard Mourani <gmourani@videotron.ca> #Change the 5 variables below to fit your computer/backup COMPUTER=deep # name of this computer DIRECTORIES="/home" # directoris to backup BACKUPDIR=/mnt/backups # where to store the backups TIMEDIR=/mnt/backups/last-full # where to store time of full backup TAR=/bin/tar # name and locaction of tar #You should not have to change anything below here PATH=/usr/local/bin:/usr/bin:/bin DOW=`date +%a` # Day of the week e.g. Mon DOM=`date +%d` # Date of the Month e.g. 27 DM=`date +%d%b` # Date and Month e.g. 27Sep # On the 1st of the month a permanet full backup is made # Every Sunday a full backup is made - overwriting last Sundays backup # The rest of the time an incremental backup is made. Each incremental # backup overwrites last weeks incremental backup of the same name. # # if NEWER = "", then tar backs up all files in the directories # otherwise it backs up files newer than the NEWER date. NEWER # gets it date from the file written every Sunday. # mount drive if mount | grep sda then cat /bin/date>/dev/null #nothing else mount /dev/sda /mnt>/dev/null fi # Monthly full backup if [ $DOM = "01" ]; then NEWER="" $TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES>/dev/null fi # Weekly full backup if [ $DOW = "Sun" ]; then NEWER="" NOW=`date +%d-%b` # Update full backup date echo $NOW > $TIMEDIR/$COMPUTER-full-date $TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES>/dev/null # Make incremental backup - overwrite last weeks else # Get date of last full backup NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`" $TAR $NEWER -chf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES>/dev/null fi # umount drive if mount | grep sda then umount /dev/sda>/dev/null fi |
Hi,
tar removes the leading slash by default. 2 ways of getting rid of this message: 1) use tar's -p option 2) use grep -v to get rid of this message. Be sure to know the implementations of tarring files _with_ the leading slash (-p option)!! The creation is not effected, but during extraction you could end up with problems because the filepath is 'hard'. Hope this helps. |
Thanks, but it didn't help.
Hmmmm... I'm using Debian Woody. Grep doesn't have a -v switch and tar doesn't have a -p switch. I silenced the greps by sending the output to /dev/null but I still can't silence tar. Tar says: /bin/tar: Removing leading `/' from member names even if I send it to /dev/null. |
Hi again,
No -v option for grep? That I don't believe....... Same about the -p option for tar. I must admit that it should be -P, not -p but both are there. tar --help and man grep for details about these options. If you want to redirect the output you also need to redirect the errors (stderr), so do: > dev/null 2>&1 instead of only >/dev/null Hope this helps. |
that did it, thanks!
|
Hey all,
I'm having the same problem: /etc/cron.daily/backup.cron: /bin/tar: Removing leading `/' from member names You mentioned to use grep -v or tar -p and > dev/null 2>&1 instead of only >/dev/null Where does this info go? Correct me if I am wrong but doesn't > dev/null 2>&1 instead of only >/dev/null go in the cromtab file? How about the grep -v or tar -p solution? Thanks, |
Hi,
It does not matter where you put the >/dev/null 2>&1. Personally I like my crontab as clean as possible and like to handle output from within the script. tar -P (capital) makes sure that tar does not strip the leading /. Like I stated in post #2: Do know what this implies during restore. If you use >/dev/null 2>&1 after your tar command you don't need the grep -v. If you use tar -P you don't need the /de/null..... and/or the grep -v Hope this helps. |
Thanks so much for the reply, below is a copy of the file. Can you do me a big favor and point out where I need to place this extra bit of code?
Can you please explain what you ment in Post 2? Is this a bad thing to do, the tar -P? ************************************ COMPUTER=**** # name of this computer DIRECTORIES="*****" # directoris to backup BACKUPDIR=/backups # where to store the backups TIMEDIR=/backups/last-full # where to store time of full backup TAR=/bin/tar # name and locaction of tar #You should not have to change anything below here PATH=/usr/local/bin:/usr/bin:/bin DOW=`date +%a` # Day of the week e.g. Mon DOM=`date +%d` # Date of the Month e.g. 27 DM=`date +%d%b` # Date and Month e.g. 27Sep # On the 1st of the month a permanet full backup is made # Every Sunday a full backup is made - overwriting last Sundays backup # The rest of the time an incremental backup is made. Each incremental # backup overwrites last weeks incremental backup of the same name. # # if NEWER = "", then tar backs up all files in the directories # otherwise it backs up files newer than the NEWER date. NEWER # gets it date from the file written every Sunday. # Monthly full backup if [ $DOM = "1" ]; then NEWER="" $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES fi # Weekly full backup if [ $DOW = "Thu" ]; then NEWER="" NOW=`date +%d-%b` # Update full backup date echo $NOW > $TIMEDIR/$COMPUTER-full-date $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES # Make incremental backup - overwrite last weeks else # Get date of last full backup NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`" $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES ************************** Does it go after TAR=/bin/tar? Thanks, LS |
Hi,
About tar -P: This option will not strip the leading / from paths. Untarring the created archive will place the file at the 'hard' location (i.e. /etc/fstab will be placed at /etc/fstab). This sounds great, but is often unwanted because it overwrites the excisting file(s) without asking. Without the -P tar will strip the leading / (/etc/fstab becomes etc/fstab). If you untar the archive in say /tmp, /tmp/etc/fstab is created and the original /etc/fstab is left alone. It's then up to you to decide which files do actually need to be replaced. Tarring without the -P option is saver, although it takes a bit more time. This will not use the -P option, but does throw away the message about it: Add the bold part to all three instances in your backup script: $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES >/dev/null 2>&1 If you do want to use the -P option, add the bold part to all three instances: $TAR -P $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES Hope this clears things up. |
It would probably be easiest to just add the > /dev/null 2>&1 inside the crontab. Otherwise you need to add it to the end of each line in the script that starts with $TAR. By doing this you basically redirect all output from tar to the trash. Cron is designed so that anything that is output by the programs it runs will be emailed to the user. We just prevent cron from receiving any of this output.
|
Thanks so much, I'll let you know if that work...I also get the following error in the same email:
/etc/cron.daily/00webalizer: Error: Skipping oversized log record Warning: Truncating oversized referrer field removed the 00webalizer file so I wont get them anymore, but I was wondering if this looks familiar to you. I looked on line and couldnt find a fix for it, everyine just says to remove it. any ideas? thanks a bunch Lenny |
All times are GMT -5. The time now is 03:25 PM. |