# backup_config_storage_ibm.sh
#!/bin/bash #set -x # #@(#) Script to backup svc # # version: 1.1 03-2022 eif # dir=`dirname $0` . $dir/.env # Variables destination="mail@test.lu" user_repoting="report" SSH="ssh -o ConnectTimeout=30 ${user_repoting}@" logfile=$logpath/list_storage_users.txt list=$binpath/storage_list.txt savedir=/workdir/svc/backup svc_user="report" DATE=$(date +%Y%m%d) DAY=$(date +%d) # backup rotation 30 days # create backup folder if [[ ! -d $savedir ]] then mkdir -p $savedir fi #---------------------- backup_svc () { date '+%Y-%m-%d %H:%M:%S' for storage in $(cat ${list}) do connection="${svc_user}@${storage}" savedir1=$savedir/$storage if [[ ! -d $savedir1 ]] then mkdir -p $savedir1 fi rm -f $savedir1/svc.config.backup* >/dev/null 2>&1 echo "### Start Backup of storage:$(date '+%Y-%m-%d %H:%M:%S') $storage" ssh $connection svcconfig backup RC=$? if [[ $RC != 0 ]] then echo "# Backup failure on storage: ${storage}" mailx -s "Backup failure on storage: ${storage}" $destination exit 1 else echo "# Backup Success on storage: ${storage}" fi echo "### Copy Backup of storage: $storage" scp $connection:/dumps/svc.config.backup* $savedir1 RC=$? if [[ $RC != 0 ]] then echo "#******* Copy Backup failure (scp) for storage: ${storage}" mailx -s "Copy Backup failure (scp) for storage: ${storage}" $destination exit 1 else echo "# Copy Backup Success (scp) for storage: ${storage}" fi # compress backup.... + delete old files (30 j) cd $savedir1 rm -f svc_conf_backup_$DAY.tar* >/dev/null 2>&1 tar -cvf svc_conf_backup_$DAY.tar svc.config.backup* gzip svc_conf_backup_$DAY.tar echo done date '+%Y-%m-%d %H:%M:%S' } ######################### # Main ######################### main () { backup_svc } main > $logname.$(date '+%u') 2>&1
Disable LUN in thinprovision warning threshold
# chvdisk_warning.sh
#!/bin/bash # #@(#) Scripts to remove warning threshold on volumes # # version: 1.0 10-2023 Manu dir=`dirname $0` . $dir/.env DATE=$(date +%Y%m%d) YEAR=$(date +%Y) MONTH=$(date +%m) user_repoting="report" SSH="ssh -o ConnectTimeout=30 ${user_repoting}@" list=$binpath/storage_list.txt storage=v7000-01 #---------------------- get_disklist () { date ${SSH}${storage} "lsvdisk -delim : -nohdr" > $logpath/lsvdisk.${storage}.txt for vol in $(cat $logpath/lsvdisk.${storage}.txt | cut -d':' -f2 | sort -u) do echo "$vol: "$(${SSH}${storage} "lsvdisk $vol" | egrep 'warning|copy_id') done > $logpath/lsvdisk.${storage}.warning } #---------------------- generate_svccmd () { for line in $(cat $logpath/lsvdisk.${storage}.warning | sed 's/\ copy_id/,copy_id/g' | sed 's/\ /;/g') do vdisk=$(echo $line | cut -d':' -f1) line1=$(echo $line | cut -d':' -f2- | sed 's/,//' | cut -d',' -f1) copy1=$(echo $line1 | sed 's/copy_id;//' | cut -d';' -f1) warning1=$(echo $line1 | cut -d';' -f4) line2=$(echo $line | cut -d':' -f2- | sed 's/,//' | cut -d',' -f2- | sed 's/,//') copy2=$(echo $line2 | sed 's/copy_id;//' | cut -d';' -f1) warning2=$(echo $line2 | cut -d';' -f4) if [[ "$warning1" -ne "" ]] then if [[ "$warning1" -ne "0" ]] then echo "chvdisk -copy $copy1 -warning 0 $vdisk" fi fi if [[ "$warning2" -ne "" ]] then if [[ "$warning2" -ne "0" ]] then echo "chvdisk -copy $copy2 -warning 0 $vdisk" fi fi done } ######################### main () { date echo "*** Get SVC disk list" get_disklist echo "*** Generate SVC cmd" generate_svccmd > $logpath/chvdisk.cmd } main > $logname 2>&1 cat $logpath/chvdisk.cmd
Daily copy auditlog into a file and consolidate per year
# check_audit_log.sh
#!/bin/bash # #@(#) Scripts to collect auditlogs from SVC / V7K users, once per day # archived by month / year and visible on wiki # # version: 1.0 01-2020 Manu dir=`dirname $0` . $dir/.env DATE=$(date +%Y%m%d) YEAR=$(date +%Y) MONTH=$(date +%m) workdir=/workdir/svc/backup/auditlog savedir=$workdir/$YEAR index=$workdir/auditlog.txt user_repoting="report" SSH="ssh -o ConnectTimeout=30 ${user_repoting}@" list=$binpath/storage_list.txt # create backup folder if [[ ! -d $savedir ]] then mkdir -p $savedir fi #---------------------- get_auditlog () { date for storage in $(cat ${list}) do echo "Audit log for $storage" if [ -f $savedir/${storage}_${MONTH}.out ] then cp $savedir/${storage}_${MONTH}.out $savedir/${storage}_${MONTH}.log fi ${SSH}${storage} "catauditlog -delim ';'" >> $savedir/${storage}_${MONTH}.log cat $savedir/${storage}_${MONTH}.log | sort -u > $savedir/${storage}_${MONTH}.out done } #---------------------- generate_log_file () { # find all files .out create up to 300 days # Formating page for Dokuwiki echo "====== Last User Audit log for storage ======" > ${index} echo "" >> ${index} for storage in $(cat ${list}) do Ustorage=$(echo ${storage} | tr 'a-z' 'A-Z') output=$workdir/auditlog_${storage}.txt cat /dev/null > $output for file1 in $(find $workdir -name "${storage}_*.out" -mtime -300) do cat $file1 | grep -v "/dumps/svc.config" | sort -u >> $output done cat $output | sort -u > $output.2 tac $output.2 > $output.1 echo "====== Last Changes on ${Ustorage} ======" > $output date "+%d-%m-%Y %H:%M" >> $output echo '<code>' >> $output cat $output.1 >> $output echo '
' » $output
echo "[[storage:svc:auditlog_${storage}|${Ustorage}]]" >> ${index} echo "" >> ${index} rm -f $output.1 $output.2
done }
#———————————————— send_wiki() { dokupath=/var/www/html/dokuwiki/data/pages/storage/svc dokuuser=apache dokugrp=apache
for file1 in auditlog_*.txt do
sudo su - root -c "/bin/cp $workdir/$file1 $dokupath"
done
sudo su - root -c “/bin/cp ${index} $dokupath” sudo su - root -c “/bin/chown -R $dokuuser.$dokugrp $dokupath”
}
######################### # Main ######################### main () { date echo “* Get audit log on storage” get_auditlog echo “* Generate main audit log file” generate_log_file echo “*** Copy to Wiki” send_wiki }
main > $logname 2>&1 </code>