-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path1050_source_apps_processing.sh
197 lines (194 loc) · 7.31 KB
/
1050_source_apps_processing.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
#
#####################################################################################################
# S T A G I N G O V E R L A Y - Source Apps Tasks #
# 1050_source_apps_processing.sh #
#####################################################################################################
#
# Import properties file
#
. clone_environment.properties
#################################################
# Default Configuration #
#################################################
trgbasepath="${basepath}targets/"
logfilepath="${basepath}logs/"
functionbasepath="${basepath}function_lib/"
custfunctionbasepath="${basepath}custom_lib/"
custsqlbasepath="${custfunctionbasepath}sql/"
sqlbasepath="${functionbasepath}sql/"
rmanbasepath="${functionbasepath}rman/"
abendfile="$trgbasepath""$trgappname"/"$trgappname"_1050_abend_step
logfilename="$trgdbname"_Overlay_Apps_PART1$(date +%a)"_$(date +%F).log"
####################################################################################################
# add functions library #
####################################################################################################
. ${functionbasepath}/usage.sh
. ${functionbasepath}/syncpoint.sh
. ${functionbasepath}/send_notification.sh
. ${functionbasepath}/os_tar_gz_file.sh
. ${functionbasepath}/os_delete_move_file.sh
. ${functionbasepath}/os_user_check.sh
. ${functionbasepath}/os_verify_or_make_directory.sh
. ${functionbasepath}/os_verify_or_make_file.sh
. ${functionbasepath}/is_os_file_exist.sh
. ${functionbasepath}/error_notification_exit.sh
#
########################################
# VALIDATIONS #
########################################
#
if [ $# -lt 2 ]
then
echo " ====> Abort!!!. Invalid apps arguments for overlay"
usage $0 :1000_overlay_staging "[APPS NAME] [TIER NO 1..3]"
########################################################################
# send notification and exit #
########################################################################
send_notification "$trgappname"_Overlay_abend "Invalid apps name for replication" ${TOADDR} ${RTNADDR} ${CCADDR}
exit 3
fi
#
unset tier
tier=$2
#
#
# Check user
#
os_user_check ${appsosuser}
rcode=$?
if [ "$rcode" -gt 0 ]
then
error_notification_exit $rcode "Wrong os user, user should be ${appsosuser}!!" $trgappname 0 $LINENO
fi
#
# Validate Directory
#
os_verify_or_make_directory ${logfilepath}
os_verify_or_make_directory ${appsourcebkupdir}
os_verify_or_make_directory ${trgbasepath}
os_verify_or_make_directory ${trgbasepath}${srcappname}
os_verify_or_make_file ${abendfile} 0
#
# Verify Apps environment
#
if [[ -n "${TWO_TASK+1}" && $TWO_TASK == $srcappname ]]
then
echo "Environment is correct!"
else
echo "Environment is not set or wrong environment to clone."
error_notification_exit $rcode "Wrong Enviornment to clone $trgappname !!" $srcappname 0 $LINENO
fi
############################################################
restart=false
while read val1 val2
do
stepnum=$val1
linenum=$val2
if [[ "$stepnum" != "0" ]]
then
restart=true
echo ""
echo " RESTART LOCATION: "$stepnum" ,around line: "$linenum""
echo " SCRIPT LOCATION: ${basepath}$0"
echo "TASK LOG LOCATION: ${trgbasepath}${trgdbname}/"
echo " RUN LOG LOCATION: ${logfilepath}"
echo ""
else
echo ""
echo " NORMAL LOCATION: "$stepnum" ,line: "$linenum""
echo " SCRIPT LOCATION: ${basepath}$0"
echo "TASK LOG LOCATION: ${trgbasepath}${trgdbname}/"
echo " RUN LOG LOCATION: ${logfilepath}"
echo ""
stepnum=`expr $stepnum + 50`
fi
done < "$abendfile"
#
now=$(date "+%m/%d/%y %H:%M:%S")
echo $now >>$logfilepath$logfilename
#
now=$(date "+%m/%d/%y %H:%M:%S")" ====> ######## $srcappname to $trgappname overlay has been started - PART1 ########"
echo $now >>$logfilepath$logfilename
#
for step in $(seq "$stepnum" 50 300)
do
case $step in
"50")
###################################################
# send notification that APPS overlay started #
###################################################
echo "START TASK: $step send_notification"
send_notification "$srcappname"_backup_started "$srcappname backup started" ${TOADDR} ${RTNADDR} ${CCADDR}
#
########################################
# write an audit record in the log #
########################################
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Send start $srcappname apps backup Notification"
echo $now >>$logfilepath$logfilename
#
echo "END TASK: $step send_notification"
;;
# "100")
########################################
# check source apps status #
########################################
"150")
########################################
# delete or move old backup #
########################################
echo "START TASK: $step os_delete_move_file"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Delete/Move $srcappname old backups"
echo $now >>$logfilepath$logfilename
#
if is_os_file_exist ${appsourcebkupdir}${srcappname}${tier}.tar.gz
then
appender=$(date "+%m%d%y%H%M%S")
echo "Moving previous backup file ${appsourcebkupdir}${srcappname}${tier}.tar.gz ${appsourcebkupdir}${srcappname}${tier}.tar.gz.$appender"
os_delete_move_file D ${appsourcebkupdir}${srcappname}${tier}.tar.gz ${appsourcebkupdir}${srcappname}${tier}.tar.gz.$appender
fi
#
rcode=$?
if [ "$rcode" -gt 0 ]
then
error_notification_exit $rcode "Moving/Deleting old backup file FAILED!!" $trgappname $step $LINENO
fi
echo "END TASK: $step os_delete_move_file"
;;
"200")
#########################################
# delete old bckup completed #
#########################################
echo "START TASK: $step os_tar_gz_file"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Delete $srcappname old backups completed"
echo $now >>$logfilepath$logfilename
#
########################################
# Start Source apps backups #
########################################
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Start $srcappname new backups"
echo $now >>$logfilepath$logfilename
#
echo taring ${appsourcehomepath} to ${appsourcebkupdir}${srcappname}${tier}.tar.gz
os_tar_gz_file ${appsourcebkupdir}${srcappname}${tier}.tar.gz "EBSapps" ${appsourcehomepath} ${srcappname}${tier}_tarbackup.log
rcode=$?
if [ $? -ne 0 ]
then
error_notification_exit $rcode "$srcappname apps backup FAILED. Abort!!" $trgappname $step $LINENO
fi
echo "END TASK: $step os_tar_gz_file"
;;
# "250")
########################################
# check source apps after backups #
########################################
"300")
echo "START TASK: $step end-of $srcappname app backup"
syncpoint $srcappname "0 " "$LINENO"
echo "END TASK: $step end-of $srcappname app backup"
;;
*)
echo "step not found - step: $step around Line ===> " "$LINENO"
;;
esac
done