Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-01-2005, 09:04 AM
|
#1
|
LQ Newbie
Registered: Mar 2005
Posts: 3
Rep:
|
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
|
|
|
03-01-2005, 10:07 AM
|
#2
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
03-01-2005, 03:04 PM
|
#3
|
LQ Newbie
Registered: Mar 2005
Posts: 3
Original Poster
Rep:
|
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.
|
|
|
03-01-2005, 03:35 PM
|
#4
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
03-01-2005, 04:58 PM
|
#5
|
LQ Newbie
Registered: Mar 2005
Posts: 3
Original Poster
Rep:
|
that did it, thanks!
|
|
|
03-21-2005, 09:32 AM
|
#6
|
Member
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101
Rep:
|
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,
|
|
|
03-21-2005, 09:53 AM
|
#7
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
Last edited by anon237; 03-21-2005 at 09:54 AM.
|
|
|
03-21-2005, 09:58 AM
|
#8
|
Member
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101
Rep:
|
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
|
|
|
03-21-2005, 10:09 AM
|
#9
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
03-21-2005, 10:21 AM
|
#10
|
Member
Registered: Feb 2003
Distribution: VectorLinux 5.1
Posts: 116
Rep:
|
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.
|
|
|
03-21-2005, 10:23 AM
|
#11
|
Member
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101
Rep:
|
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 02:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|