tstream02:vmlin32dev25:~>
tstream02:vmlin32dev25:~>cat siteBackup.sh
#!/bin/bash
#
# Backup all directories within webroot
# use empty file ".DONT_BACKUP" to exclude any directory
 
 
# days to retain backup. Used by recycler script
DEFRETAIN=14
LOGFILE=/export/home/tstream02/.site_backup/WebrootBackup.log
#
#
BU_FILE_COUNT=0
#
# and name of backup source subfolder under the users home
WEBDIR=webroot
#
# and name of dest folder for tar files
DESDIR=.site_backup
 
#alright, thats it for config, the rest is script
#########################################
 
 
cd ${HOME}/
 
 
TODAY=`date`
BU_FILE_COUNT=0
suffix=$(date +%m-%d-%Y)
LIST="/export/home/tstream02/tmp/backlist_$$.txt"
printf "\n\n********************************************\n\tSite Backup r Log for:\n\t" | tee -a $LOGFILE
echo $TODAY | tee -a $LOGFILE
printf "********************************************\n" $TODAY | tee -a $LOGFILE
echo "see ${LOGFILE} for details"
 
#for DIR in $(ls | grep ^[a-z.]*$)
set $(date)
#

 
for DIR in $(ls )
do
        echo $DIR >> $LOGFILE
        #tar the current directory
        if [ -f $DIR/.DONT_BACKUP ]
        then
 
                printf "\tSKIPPING $DIR as it contains ignore file\n" >> $LOGFILE
 
        else
                  if [ -d $DIR/conf  ]
                  then
                        echo $DIR/conf
                        cpath=${HOME}/${DESDIR}/${DIR}
                        #
                        #check if we need to make path
                        #
                        if [ -d $cpath ]
                        then
                                # direcotry exists, we're good to continue
                                filler="umin"
                        else
                                echo Creating $cpath
                                mkdir -p $cpath
                                echo $DEF_RETAIN > $cpath/.RETAIN_RULE
                        fi
                        #
 
                        if  test "$1" = "Sun" ; then
                                tar -zcf ${HOME}/${DESDIR}/${DIR}/${DIR}_$suffix.tar.gz ./$DIR/conf
                        else
                                find $DIR -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
                                tar cfzT "${HOME}/${DESDIR}/${DIR}/${DIR}_${suffix}.tar.gz"  "$LIST"
                                rm -f "$LIST"
                        fi
                        if [ -d $DIR/tools ]
                        then
                                prodName=$(basename $DIR)
                                prodNameInfo=${prodName}info
                                #echo "this is the prodnameinfo"
                                #echo $DIR/tools/$prodNameInfo
                                if [ -f $DIR/tools/$prodNameInfo ]
                                then
                                        $DIR/tools/$prodNameInfo > ${HOME}/${DESDIR}/${DIR}/info
                                fi
                        fi
                        BU_FILE_COUNT=$(( $BU_FILE_COUNT + 1 ))
                  else
                        for sDIR in $(find $DIR -name "conf")
                        do
                                cpath=${HOME}/${DESDIR}/${sDIR}
                                echo $sDIR
                                #check if we need to make path
                                #
                                if [ -d $cpath ]
                                then
                                        # direcotry exists, we're good to continue
                                        filler="umin"
                                else
                                        echo Creating $cpath
                                        mkdir -p $cpath
                                        echo $DEF_RETAIN > $cpath/.RETAIN_RULE
                                fi
                                tmp=$(basename $sDIR)
                                tar -zcf ${HOME}/${DESDIR}/${sDIR}/${tmp}_${suffix}.tar.gz ./$sDIR
                                BU_FILE_COUNT=$(( $BU_FILE_COUNT + 1 ))
                        done

                fi
        fi
 
done
printf "\n\n********************************************\n" | tee -a $LOGFILE
echo $BU_FILE_COUNT sites were backed up
printf "********************************************\n" $TODAY | tee -a $LOGFILE