Sie sind auf Seite 1von 4

###

# copyToStaticFrozen.sh - script to copy Frozen Splunk data to StaticFrozen

# Version - 1.0

# Location - /opt/splunk/bin/scripts

# Usage - This script will copy files from frozen to static frozen once

# per month

# Write the logs of this file to

# > $SPLUNK_HOME/var/log/copyToStaticFrozen.log

##

# Change Control:

# # ver # date # implementor # changes #

# ############################################################################

SPLUNK_HOME=/opt/splunk

. $SPLUNK_HOME/bin/scripts/archive.properties

logRotate ()

# Rotate the Log File

sh $SPLUNK_HOME/bin/scripts/rotateLogFile.sh copyToStaticFrozen.log

archive_successful=$(cat $archive_result_file 2>/dev/null)


if [ "$archive_successful" == "false" ]

then

echo $(date +"%d/%m/%Y %H:%M:%S") Copy Failure. Previous Month\'s issue unresolved. Please
correct by inspecting netbackup and re-running checkArchive.sh

echo $(date +"%m-%d-%Y %H:%M:%S") ERROR Backup Failure - Copy Failure. Previous Month\'s issue
unresolved. Please correct by inspecting netbackup and re-running checkArchive.sh >>
/opt/splunk/var/log/splunk/audit.log

else

for((i=0;i<$static_frozen_length;i++))

do

if [ ! -d ${static_frozen[$i]}/$this_month_dir ]

then

echo Creating Directory ${static_frozen[$i]}/$this_month_dir

mkdir ${static_frozen[$i]}/$this_month_dir

if [ $? != 0 ] //$? = exit status of the last command, if exit status of the previous command is not
successful, then throw error message

then

echo $(date +"%d/%m/%Y %H:%M:%S") Backup Failure for ${static_frozen[$i]}/$this_month_dir.


Insufficient permissions on directory.

logRotate

exit 1

fi

fi

cd ${frozen[$i]}

for index_directory in $(ls)

do

if [ $index_directory != "old" ]

then
if [ ! -d ${static_frozen[$i]}/$this_month_dir/$index_directory ]

then

echo Creating Directory ${static_frozen[$i]}/$this_month_dir/$index_directory

mkdir -p ${static_frozen[$i]}/$this_month_dir/$index_directory

fi

cd $index_directory

cd_result=$?

echo Searching $index_directory...

for directory in $(find db* rb* -maxdepth 0 -type d)

do

let directory_epoch_date=$(echo $directory | awk '{split($0,timestamp,"_"); print


timestamp[2]}') \\gives first epoch from filename

if [ $directory_epoch_date -lt $this_month_epoch ]

then

echo Copy $directory to ${static_frozen[$i]}/$this_month_dir/$index_directory

mv $directory ${static_frozen[$i]}/$this_month_dir/$index_directory

fi

done

if [[ $cd_result == 0 ]]

then

cd ..

fi

fi

done

done

echo $(date +"%d/%m/%Y %H:%M:%S") Copy Successful


fi

logRotate

Das könnte Ihnen auch gefallen