Top
ETERNUS SF AdvancedCopy Manager 14.2 Operator's Guide

A.2.2 Post-processing of backup

The name of a script file for post-processing of a backup is as follows.

In the case of non-cluster operation
/etc/opt/FJSVswsts/sh/OpcBackup.post
In the case of cluster operation
/etc/opt/FJSVswsts/<logic node name>/sh/OpcBackup.post

A.2.2.1 Post-processing script for backup

  1: #!/bin/sh
  2: 
  3: # AdvancedCopy Manager
  4: # All Rights Reserved, Copyright FUJITSU LIMITED, 2002-2009
  5: 
  6: #
  7: # Post-processing of backup processing
  8: #
  9: #        Argument: $1 Device or VG name of transaction disk
 10: #                         $2 Mount point of transaction disk
 11: #
 12: #Error number
 13: #                2: Argument error
 14: #               11: mount error
 15: #               31: vgcfgrestore error
 16: #               12: fsck error
 17: 
 18: # Argument check
 19: case $# in
 20: 1)
 21:    ;;
 22: 2)
 23:    ;;
 24: *)
 25:    exit 2
 26:    ;;
 27: esac
 28: 
 29: device=$1
 30: mount_point=$2
 31: 
 32: # Determination of postprocessing file name
 33: 
 34: if [ "$SWSTGNODE" != "" ]
 35: then
 36:    swstg_node="/`echo $SWSTGNODE`"
 37: else
 38:    swstg_node=""
 39: fi
 40: 
 41: err_log_path="/var/opt/FJSVswsts"$swstg_node"/log"
 42: 
 43: # Device type check
 44: trans="`echo $device | /usr/bin/grep -e "/dev/dsk/" -e "/dev/disk/"`"
 45: lvmtrans="`echo $device | /usr/bin/grep "/dev/"`"
 46: vxpvtrans="`echo $device | /usr/bin/grep "/dev/vx/dmp/"`"
 47: if [ "$trans" != "" ]
 48: then
 49:    dev_type="physical"
 50:    dev="`echo $device | /usr/bin/sed -e "s/\/dev\/dsk\///" -e "s/\/dev\/disk\//_hppv_/"`"
 51:    post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
 52:    fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype"
 53:    bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd"
 54: elif [ "$vxpvtrans" != "" ]
 55: then
 56:    dev_type="vxvm_pv"
 57:    # /dev/vx/dmp/XXXX -> XXXX
 58:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $5 }'`"
 59:    post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
 60:    fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype"
 61:    bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd"
 62: elif [ "$lvmtrans" != "" ]
 63: then
 64:    dev_type="logical"
 65:    # /dev/vgXX -> vgXX
 66:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
 67:    post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
 68:    fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype"
 69:    bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd"
 70: else
 71:    exit 0
 72: fi
 73: 
 74: # Confirmation of postprocessing
 75: if [ ! -r $post_file ]
 76: then
 77:    exit 0
 78: fi
 79: post="`/usr/bin/cat $post_file`"
 80: 
 81: # Confirmation of FStype
 82: if [ ! -r $fstype_file ]
 83: then
 84:    fs=""
 85: else
 86:    fs="`/usr/bin/cat $fstype_file`"
 87: fi
 88: 
 89: # Restore VG Configuration
 90: if [ -r $bd_file ]
 91: then
 92:    bk_device="`/usr/bin/cat $bd_file`"
 93:    bk_trans="`echo $bk_device | /usr/bin/grep -e "/dev/dsk/" -e "/dev/disk/"`"
 94:    bk_lvmtrans="`echo $bk_device | /usr/bin/grep "/dev/"`"
 95:    bk_vxpvtrans="`echo $bk_device | /usr/bin/grep "/dev/vx/dmp/"`"
 96:    if [ "$bk_trans" = "" -a "$bk_lvmtrans" != "" -a "$bk_vxpvtrans" = "" ]
 97:    then
 98:       bk_vg_name="`echo $bk_device |/usr/bin/awk -F\/ '{ print $3 }'`"
 99:       cfg_file="/etc/lvmconf/"$bk_vg_name".conf"
100:       if [ ! -r $cfg_file ]
101:       then
102:          exit 31
103:       fi
104:       bk_pv_rname="`/usr/sbin/vgcfgrestore -n $bk_device -l 2> /dev/null |/usr/bin/awk '{print $1}' | /usr/bin/grep -e \"/dev/rdsk\" -e \"/dev/rdisk\"`"
105:       if [ "$bk_pv_rname" = "" ]
106:       then
107:          echo "NULL: /usr/sbin/vgcfgrestore -n $bk_device -l 2> /dev/null |/usr/bin/awk '{print $1}' | /usr/bin/grep -e \"/dev/rdsk\" -e \"/dev/rdisk\"" > $err_log_path/$dev.vgcfgrestore
108:          exit 31
109:       fi
110:       /usr/sbin/vgchange -a n $bk_device > /dev/null 2>&1
111:       reststatus=0
112:       for bk_pv_rname1 in $bk_pv_rname
113:       do
114:          /usr/sbin/vgcfgrestore -n $bk_device $bk_pv_rname1 > /dev/null 2>&1
115:          if [ $? != 0 ]
116:          then
117:             /usr/sbin/vgcfgrestore -n $bk_device $bk_pv_rname1 >> $err_log_path/$dev.vgcfgrestore 2>&1
118:          fi
119:          if [ $? = 0 ]
120:          then
121:             /usr/bin/rm -f $err_log_path/$dev.vgcfgrestore
122:             reststatus=1
123:             break
124:          fi
125:       done
126:       if [ "$SWSTGNODE" != "" ]
127:       then
128:          /usr/sbin/vgchange -c y $bk_device > /dev/null 2>&1
129:          /usr/sbin/vgchange -a e $bk_device > /dev/null 2>&1
130:       else
131:          /usr/sbin/vgchange -a y $bk_device > /dev/null 2>&1
132:       fi
133:       if [ $reststatus = 0 ]
134:       then
135:          exit 31
136:       fi
137:  fi
138: fi
139: 
140: # No processing
141: # When device was not mounted --- 3
142: # When devices of volume group was not mounted --- 6
143: # When the transaction disk is a VxVM physical volume --- 7
144: if [ "$post" = "none" ]
145: then
146:    /usr/bin/rm -rf $post_file 2> /dev/null
147:    /usr/bin/rm -rf $fstype_file 2> /dev/null
148:    /usr/bin/rm -rf $bd_file 2> /dev/null
149:  exit 0
150: fi
151: 
152: # mount processing
153: if [ "$post" = "mount" ]
154: then
155: 
156:    # When device can be unmounted --- 2
157:    if [ "$dev_type" = "physical" ]
158:    then
159:       /usr/bin/df -l $device > /dev/null 2>&1
160:       if [ $? != 0 ]
161:       then
162:          if [ ! -r $fstype_file ]
163:          then
164:             /usr/sbin/mount $device $mount_point 2> /dev/null
165:          else
166:             if [ "$fs" = "" ]
167:             then
168:                /usr/sbin/mount $device $mount_point 2> /dev/null
169:             else
170:                /usr/sbin/mount -F $fs $device $mount_point 2> /dev/null
171:             fi
172:          fi
173:          if [ $? != 0 ]
174:          then
175:             retry_count=3
176:             sleep_time=1
177:             result_flag=1
178: 
179:             while [ $retry_count -gt 0 ]
180:             do
181:                if [ ! -r $fstype_file ]
182:                then
183:                   /usr/sbin/mount $device $mount_point > $err_log_path/$dev.mount 2>&1
184:                else
185:                   if [ "$fs" = "" ]
186:                   then
187:                      /usr/sbin/mount $device $mount_point > $err_log_path/$dev.mount 2>&1
188:                   else
189:                      /usr/sbin/mount -F $fs $device $mount_point > $err_log_path/$dev.mount 2>&1
190:                   fi
191:                fi
192:                if [ $? != 0 ]
193:                then
194:                   retry_count=`expr $retry_count - 1`
195:                   /usr/bin/sleep $sleep_time
196:                else
197:                   /usr/bin/rm -f $err_log_path/$dev.mount
198:                   result_flag=0
199:                   break
200:                fi
201:             done
202: 
203:             if [ $result_flag != 0 ]
204:             then
205:                exit 11
206:             fi
207:          fi
208:       fi
209: #  elif [ "$dev_type" = "logical" ]
210: #  then
211: #
212: #  When devices of volume group can be unmounted --- 5
213: #  # Specify the name of volume group to mount
214: #     if [ "$device" = "/dev/vgXX" ]
215: #     then
216: #        # Mount all logical volumes of the volume group
217: #        fs="hfs"
218: #        lvname="/dev/vgXX/XXXXX"
219: #        lv_mount_point="/XX"
220: #
221: #        /usr/bin/df -l $lvname > /dev/null 2>&1
222: #        if [ $? != 0 ]
223: #        then
224: #           /usr/sbin/mount -F $fs $lvname $lv_mount_point 2> /dev/null
225: #           if [ $? != 0 ]
226: #           then
227: #              retry_count=3
228: #              sleep_time=1
229: #              result_flag=1
230: 
231: #              while [ $retry_count -gt 0 ]
232: #              do
233: #                  /usr/sbin/mount -F $fs $lvname $lv_mount_point > $err_log_path/$dev.mount 2>&1
234: #                 if [ $? != 0 ]
235: #                 then
236: #                    retry_count=`expr $retry_count - 1`
237: #                    /usr/bin/sleep $sleep_time
238: #                 else
239: #                    rm -f $err_log_path/$dev.mount
240: #                    result_flag=0
241: #                    break
242: #                 fi
243: #              done
244: #
245: #              if [ $result_flag != 0 ]
246: #              then
247: #                 exit 11
248: #              fi
249: #           fi
250: #        fi
251: #     fi
252: 
253:    fi
254:    /usr/bin/rm -rf $post_file 2> /dev/null
255:    /usr/bin/rm -rf $fstype_file 2> /dev/null
256:    /usr/bin/rm -rf $bd_file 2> /dev/null
257:    exit 0
258: fi
259: 
260: # fsck processing
261: # When device cannot be unmounted                  --- 1
262: # When devices of volume group cannot be unmounted --- 4
263: if [ "$post" = "fsck" ]
264: then
265:    if [ -r $bd_file ]
266:    then
267:       bk_device="`/usr/bin/cat $bd_file`"
268:       bk_trans="`echo $bk_device | /usr/bin/grep -e "/dev/dsk/" -e "/dev/disk/"`"
269:       if [ "$bk_trans" != "" ]
270:       then
271:          if [ ! -r $fstype_file ]
272:          then
273:             /usr/sbin/fsck -y $bk_device > /dev/null 2>&1
274:          else
275:             if [ "$fs" = "" ]
276:             then
277:                /usr/sbin/fsck -y $bk_device > /dev/null 2>&1
278:             else
279:                /usr/sbin/fsck -y -F $fs $bk_device > /dev/null 2>&1
280:             fi
281:          fi
282:          if [ $? != 0 ]
283:          then
284:             if [ "$fs" = "" ]
285:             then
286:                /usr/sbin/fsck -y $bk_device > $err_log_path/$dev.fsck 2>&1
287:             else
288:                /usr/sbin/fsck -y -F $fs $bk_device > $err_log_path/$dev.fsck 2>&1
289:             fi
290:             if [ $? != 0 ]
291:             then
292:                exit 12
293:             else
294:                /usr/bin/rm -f $err_log_path/$dev.fsck
295:             fi
296:          fi
297: #     else
298: #        # Specify the name of volume group to fsck
299: #        if [ "$bk_device" = "/dev/vgXX" ]
300: #        then
301: #           fs="hfs"
302: #           lvname="/dev/vgXX/rXXXXX"
303: #
304: #           fsck -F $fs -y $lvname > /dev/null 2>&1
305: #           if [ $? != 0 ]
306: #           then
307: #              if [ "$fs" = "" ]
308: #              then
309: #                 fsck -y $lvname > $err_log_path/$dev.fsck 2>&1
310: #              else
311: #                 fsck -y -F $fs $lvname > $err_log_path/$dev.fsck 2>&1
312: #              fi
313: #              if [ $? != 0 ]
314: #              then
315: #                 exit 12
316: #              else
317: #                 rm -f $err_log_path/$dev.fsck
318: #              fi
319: #           fi
320: #        fi
321:       fi
322:    fi
323:    /usr/bin/rm -rf $post_file 2> /dev/null
324:    /usr/bin/rm -rf $fstype_file 2> /dev/null
325:    /usr/bin/rm -rf $bd_file 2> /dev/null
326:    exit 0
327: fi
328: 
329: exit 0