bertieuk
IS-IT--Management
- Jun 1, 2004
- 175
I have a strange problem.
I have written a script that backs up a linux machine. If I run this script from the OS then all seems to be fine.
Put it in a cron job then only 180KB backs up. But funny thing is that this script works ok on redhat and TAO
The code is as follows......(How do I outline code on Tek Tips?)
dateselect() {
case $1
in
"1") DOW=Monday;
SHORTDOW=MON;;
"2") DOW=Tuesday;
SHORTDOW=TUE;;
"3") DOW=Wednesday;
SHORTDOW=WED;;
"4") DOW=Thursday;
SHORTDOW=THU;;
"5") DOW=Friday;
SHORTDOW=FRI;;
"6") DOW=Saturday;
SHORTDOW=SAT;;
"7") DOW=Sunday;
SHORTDOW=SUN;;
esac
}
MYDATE=`date +%u`
dateselect $MYDATE
# Clear the backup directory prior to the copy
rm -f /backup/*
if [ "$DOW" = Wednesday ]
then
cd /
tar -cvzf /backup/auth1.ptstream_FULL_WK1.tgz ./ \
--exclude='./backup' \
--exclude='./dev' \
--exclude='./initrd' \
--exclude='./opt' \
--exclude='./lost+found' \
--exclude='./misc' \
--exclude='./var/lib/mysql' \
--exclude='./var/spool' \
--exclude='./proc' \
--exclude='./floppy' \
--exclude='./lost+found' \
--exclude='./tmp' \
--exclude='./var/powermail' \
--exclude='./var/log' \
--exclude='./cdrom' \
--exclude='./mnt'
else
cd /
tar -cvzf /backup/linux1_Daily_$SHORTDOW.tgz ./home ./root ./etc
fi
Thanks
Si
I have written a script that backs up a linux machine. If I run this script from the OS then all seems to be fine.
Put it in a cron job then only 180KB backs up. But funny thing is that this script works ok on redhat and TAO
The code is as follows......(How do I outline code on Tek Tips?)
dateselect() {
case $1
in
"1") DOW=Monday;
SHORTDOW=MON;;
"2") DOW=Tuesday;
SHORTDOW=TUE;;
"3") DOW=Wednesday;
SHORTDOW=WED;;
"4") DOW=Thursday;
SHORTDOW=THU;;
"5") DOW=Friday;
SHORTDOW=FRI;;
"6") DOW=Saturday;
SHORTDOW=SAT;;
"7") DOW=Sunday;
SHORTDOW=SUN;;
esac
}
MYDATE=`date +%u`
dateselect $MYDATE
# Clear the backup directory prior to the copy
rm -f /backup/*
if [ "$DOW" = Wednesday ]
then
cd /
tar -cvzf /backup/auth1.ptstream_FULL_WK1.tgz ./ \
--exclude='./backup' \
--exclude='./dev' \
--exclude='./initrd' \
--exclude='./opt' \
--exclude='./lost+found' \
--exclude='./misc' \
--exclude='./var/lib/mysql' \
--exclude='./var/spool' \
--exclude='./proc' \
--exclude='./floppy' \
--exclude='./lost+found' \
--exclude='./tmp' \
--exclude='./var/powermail' \
--exclude='./var/log' \
--exclude='./cdrom' \
--exclude='./mnt'
else
cd /
tar -cvzf /backup/linux1_Daily_$SHORTDOW.tgz ./home ./root ./etc
fi
Thanks
Si