Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bnachtw
TSM-Scripts
Commits
d66e5656
Commit
d66e5656
authored
Nov 03, 2021
by
Bjoern Nachtwey
Browse files
skipped unused lines out, added check for instance user
parent
d76edcf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Server-Maintenance/do-housekeeping.sh
View file @
d66e5656
...
...
@@ -4,7 +4,7 @@
#
# do-housekeeping.sh
#
# script for
copying vital instance files to DRM share
# script for
doing DB2 analysis and cleaning up some log files
#
# (C) 2020, 2021 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
...
...
@@ -17,85 +17,89 @@
# 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
# 2021-10-20 0.2.1 fixed rsync, did not copy all files due to "*"
# changed find from -ctime to -mtime
# 2021-10-22 0.3 moved rsync to different script
#
##############################################################################
# take $1 as username
# expect $1 as username of instance user
# check if argument is given at all
if
[
-z
"
$1
"
]
then
echo
"No instance name given!"
echo
"usage:
$0
<Name / ID of instance owner>"
echo
"ABORT!"
exit
fi
# check if instance is located on this server
if
[
-z
$(
grep
$1
/etc/passwd
)
]
then
echo
"wrong instance name given!"
echo
"ABORT!"
exit
fi
# get date for logfiles
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
# some path settings
DB2Analysispath
=
"/tsmshare/OfflineReorg"
;
DRMdestpath
=
"/tsmshare/DRM/
$luser
"
;
# check for folders
if
[
!
-d
$sourcepath
]
then
mkdir
-p
$sourcepath
;
fi
if
[
!
-d
$upath
]
if
[
!
-d
$DB2Analysispath
/
$luser
]
then
mkdir
-p
$
upath
;
mkdir
-p
$
DB2Analysispath
/
$luser
;
fi
#################################
# do DB2 analysis
#################################
# switch to folder
cd
$
sourcepath
cd
$
DB2Analysispath
/
$luser
# get analysis
su
-c
"cd
$
sourcepath
&& perl -f /tsmshare/OfflineReorg
/analyze_DB2_formulas.pl"
-l
$luser
su
-c
"cd
$
DB2Analysispath
/
$luser
&& perl -f
$DB2Analysispath
/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
cp
$(
ls
-td
*
/
|
head
-n
1
)
/summary.out
$today
-summary
.out
cp
$today
-summary
.out
$DB2Analysispath
/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 folders containing analysis data
older than 30 days
find
$
DB2Analysispath
/
$luser
-noleaf
-mtime
+30
-type
d
-exec
rm
-rvf
{}
\;
# remove entries older than
two
year
s
find
$
DB2Analysispath
/
$luser
-noleaf
-mtime
+
750
-type
f
-exec
rm
-vf
{}
\;
#################################
# remove old
plan
files
# remove old files
#################################
find
$destpath
/
-ctime
+30
-exec
rm
-vf
{}
\;
#################################
# remove old planfiles
find
$DRMdestpath
/
-name
"planfile*"
-mtime
+30
-exec
rm
-vf
{}
\;
# remove old dsmffdc.log files
#################################
find /
$luser
/config
-name
"dsmffdc.log.*"
-ctime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/config
-name
"dsmffdc.log.*"
-mtime
+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
{}
\;
find /
$luser
/sqllib/db2dump
-name
"TSMDB1.*.events.bin"
-ctime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"db2pd.[0-9]*.*.events.bin"
-ctime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/config
-name
"dsmffdc.*.log"
-ctime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"[0-9]*.dump.bin"
-mtime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"[0-9]*.stack.txt"
-mtime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"[0-9]*.trap.txt"
-mtime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"TSMDB1.*.events.bin"
-mtime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"db2pd.[0-9]*.*.events.bin"
-mtime
+30
-exec
rm
-vf
{}
\;
find /
$luser
/config
-name
"dsmffdc.log.*"
-mtime
+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_*"
-c
time
+30
-exec
rm
-vf
{}
\;
find /
$luser
/sqllib/db2dump
-name
"db2diag*log_*"
-m
time
+30
-exec
rm
-vf
{}
\;
# remove old weblog file
rm
-f
/tsm/dsmwebcl.log
# copy / sync vital instance files
# -c checksum instead of timestamp
# -t preserve timestamp
# -u update only
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
rm
-f
/tsm/dsmwebcl.log
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment