Commit d76edcf3 authored by bnachtw's avatar bnachtw
Browse files

added heading, replaced absolute paths by variables

parent f290387d
#! /bin/bash
##############################################################################
#
# do-housekeeping.sh
#
# script for copying vital instance files to DRM share
#
# (C) 2020, 2021 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
##############################################################################
#
# changelog
# date version remark
# 2020-someday 0.1 initial coding
# 2021-someday 0.1.1 put to gitlab
# 2021-04-29 0.2 add heading, replaced absolute path by variables
# added /etc/fstab to vital files
#
##############################################################################
# take $1 as username
today=$(date +"%F")
# convert username to lowcase and upcase
luser=$(echo $1 | tr '[:upper:]' '[:lower:]');
uuser=$(echo $1 | tr '[:lower:]' '[:upper:]');
sourcepath="/tsmshare/OfflineReorg/$luser";
destpath="/tsmshare/DRM/$uuser";
set -x
# check for folders
if [ ! -d $sourcepath ]
then
mkdir -p $sourcepath;
fi
if [ ! -d $upath ]
then
mkdir -p $upath;
fi
#################################
# do DB2 analysis
su -c "cd /tsmshare/OfflineReorg/$luser && sh /tsmshare/bin/get-DB2-Analysis.sh" -l $luser
#################################
# switch to folder
cd $sourcepath
# get analysis
su -c "cd $sourcepath && perl -f /tsmshare/OfflineReorg/analyze_DB2_formulas.pl" -l $luser
# copy actual summary to latest folder
cp $(ls -td 2* | head -n 1)/summary.out $today-summary.out
cp $today-summary.out /tsmshare/OfflineReorg/Summaries/$luser-summary.out
# remove folders containing analysis data
find $sourcepath/ -noleaf -name "20*" -type d -exec rm -rvf {} \;
# remove entries older than one year
find $sourcepath/ -noleaf -mtime +366 -type f -exec rm -vf {} \;
#################################
# remove old planfiles
find /tsmshare/DRM/$uuser/ -ctime +30 -exec rm -vf {} \;
#################################
find $destpath/ -ctime +30 -exec rm -vf {} \;
#################################
# remove old dsmffdc.log files
#################################
find /$luser/config -name "dsmffdc.log.*" -ctime +30 -exec rm -vf {} \;
#################################
# remove old errorlog files
#################################
find /$luser/sqllib/db2dump -name "[0-9]*.dump.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.stack.txt" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.trap.txt" -ctime +30 -exec rm -vf {} \;
......@@ -25,6 +80,8 @@ find /$luser/config -name "dsmffdc.*.log" -ctime +30 -exec rm -vf
# prune db2diaglog and remove old files
su -c "cd /$luser/sqllib/db2dump/DIAG0000 && db2diag -A" -l $luser
su -c "cd /$luser/sqllib/db2dump && db2diag -A" -l $luser
find /$luser/sqllib/db2dump -name "db2diag*log_*" -ctime +30 -exec rm -vf {} \;
# remove old weblog file
......@@ -34,9 +91,11 @@ rm -f /tsm/dsmwebcl.log
# -c checksum instead of timestamp
# -t preserve timestamp
# -u update only
rsync -ctu /$luser/config/cert* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/devconf.dat /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmkeydb* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmserv.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/tsmdbmgr.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/volhist.dat /tsmshare/DRM/$uuser/
\ No newline at end of file
rsync -ctu /$luser/config/cert* $destpath/
rsync -ctu /$luser/config/devconf.dat $destpath/
rsync -ctu /$luser/config/dsmkeydb* $destpath/
rsync -ctu /$luser/config/dsmserv.opt $destpath/
rsync -ctu /$luser/config/tsmdbmgr.opt $destpath/
rsync -ctu /$luser/config/volhist.dat $destpath/
# copy also some files from host
rsync -ctu /etc/fstab $destpath/$(hostname).fstab
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment