Computing.Net > Forums > Unix > Backup status script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Backup status script

Reply to Message Icon

Name: sureshht
Date: March 23, 2009 at 14:20:33 Pacific
OS: AXI 5.3L
CPU/Ram: 10
Product: Ibm / P550
Subcategory: General
Comment:

Hi,

We have several backup jobs running everyday. We do get mails if job is successful/fails. For some reason, if the job didnot run, we would know the status.

I am in the process of developing script for this. I have a function in my script to find waht day it is:

Here is my script:

sid1=abcd
sid2=efgh
sid3=ijkl
sid4=mnop
sid5=qrst
sid6=uvwx


if [[ dayno -eq 1 ]]
then
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
ls $log_home/$i_level0_backup.log
if [ $? != 0 ]; then
echo "Level 0 backup for $i was not successful. Please check the log files" >> $tmpfile
echo " " >>$tmpfile
mailit=true
done

elif [[ dayno -eq 2 || dayno -eq 3 || dayno -eq 5 || dayno -eq 6 ]]
then
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
ls $log_home/$i_level2_backup.log
if [ $? != 0 ]; then
echo "Level 2 backup for $i was not successful. Please check the log files" >> $tmpfile
echo " " >>$tmpfile
mailit=true
done

elif [[ dayno -eq 4 ]]
then
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
ls $log_home/$i_level1_backup.log
if [ $? != 0 ]; then
echo "Level 1 backup for $i was not successful. Please check the log files" >> $tmpfile
echo " " >>$tmpfile
mailit=true
done
fi

I know I am doing something wrong in 'for loop' section. I am getting syntax error.

Please help.

Thanks and Regards
Suresh

sureshht



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 23, 2009 at 15:46:54 Pacific
Reply:

I found a number of problems:

1) In the 3 for loops, the inner if statement isn't terminated by an fi.
2) With a series of elif clauses, the terminating one must be a else with no then
3) variable dayno should have a $, but that may be optional depending on your shell.

Below are the changes I made using ksh. Good hunting!


if [[ $dayno -eq 1 ]]
then
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
   ls $log_home/$i_level0_backup.log
   if [ $? != 0 ]; then
   echo "Level 0 backup for $i was not successful. Please check the log files" >> $tmpfile
   echo " " >>$tmpfile
   mailit=true
   fi
done

elif [[ $dayno -eq 2 || $dayno -eq 3 || $dayno -eq 5 || $dayno -eq 6 ]]
then
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
ls $log_home/$i_level2_backup.log
if [ $? != 0 ]; then
echo "Level 2 backup for $i was not successful. Please check the log files" >> $tmpfile
echo " " >>$tmpfile
mailit=true
   fi
done

else [[ $dayno -eq 4 ]]
for i in $sid1 $sid2 $sid3 $sid4 $sid5 $sid6
do
ls $log_home/$i_level1_backup.log
if [ $? != 0 ]; then
echo "Level 1 backup for $i was not successful. Please check the log files" >> $tmpfile
echo " " >>$tmpfile
mailit=true
   fi
done
fi


0

Response Number 2
Name: sureshht
Date: March 24, 2009 at 06:32:10 Pacific
Reply:

Hi Nails,

Thanks for your response.
The 'dayno' variable without $ works for me.
The problem is : ls $log_home/$i_level1_backup.log
After $i it is not recognizing '_' (underscore).

I am getting :

ls: 0653-341 The file /.log does not exist.

Thanks and regards
Suresh

sureshht


0

Response Number 3
Name: sureshht
Date: March 24, 2009 at 06:52:46 Pacific
Reply:

Hi Nails,

Thanks for all your help.
I resolved my problem by replacing $i_level1_backup.log with ${i}_ level1_backup.log

Thanks and Regards
Suresh

sureshht


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Backup status script

Unix back up error www.computing.net/answers/unix/unix-back-up-error/5379.html

Perl Backup script www.computing.net/answers/unix/perl-backup-script/4265.html

backup a file with SHELL SCRIPT www.computing.net/answers/unix/backup-a-file-with-shell-script/4522.html