Top
ETERNUS SF AdvancedCopy Manager V16.9A Operation Guide
FUJITSU Storage

C.2.3 Post-processing When Replication Is Executed

The replication source volume script (RepSrc.post) and the replication destination volume script (RepDst.post) are prepared for a post-processing script, which is stored in the following directory. This script must be customized according to the processing requirements.

/etc/opt/FJSVswsrp/sh

Replication Source Volume Post-processing Sample Script (RepSrc.post)

  1: #!/bin/sh
  2: 
  3: # AdvancedCopy Manager
  4: # All Rights Reserved, Copyright FUJITSU LIMITED, 2004-2007
  5: 
  6: #
  7: #   Post-processing of Replication(Source) processing
  8: #
  9: #               Argument: $1 Device name of Source disk
 10: #
 11: #       Error number
 12: #               2: Argument error
 13: #              11: mount error
 14: 
 15: # Argument check
 16: case $# in
 17: 1)
 18:    ;;
 19: *)
 20:    exit 2
 21:    ;;
 22: esac
 23: 
 24: device=$1
 25: 
 26: # Determination of postprocessing file name
 27: if [ "`echo $device | /usr/bin/grep "/dev/hdisk"`" != "" ]
 28: then
 29:    dev_type="lvm_pv"
 30:    # /dev/hdisk? -> hdisk?
 31:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
 32: 
 33: elif [ "`echo $device | /usr/bin/grep "/dev/vx/dmp/"`" != "" ]
 34: then
 35:    dev_type="vxvm_pv"
 36:    # /dev/vx/dmp/device -> device
 37:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $5 }'`"
 38: 
 39: elif [ "`echo $device | /usr/bin/grep "/dev/"`" != "" ]
 40: then
 41:    dev_type="lvm_vg"
 42:    # /dev/VG_Name -> VG_Name
 43:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
 44: 
 45: else
 46:    # Other Volume
 47:    exit 0
 48: fi
 49: post_file="/etc/opt/FJSVswsrp/"$SWSTGNODE"/data/DEFAULT/"$dev".spre"
 50: 
 51: err_log_path="/var/opt/FJSVswsrp/"$SWSTGNODE"/log"
 52: 
 53: # Confirmation of postprocessing
 54: if [ ! -r $post_file ]
 55: then
 56:    exit 0
 57: fi
 58: 
 59: post="`/usr/bin/cat $post_file`"
 60: 
 61: # mount processing
 62: if [ "$post" = "mount" ]
 63: then
 64: 
 65: # When devices of volume group can be unmounted
 66: #Specify the name of volume group to mount
 67: 
 68:    if [ "$device" = "/dev/vgXX" ]
 69:    then
 70:       mount_error=0
 71:       # Mount all logical volumes of the volume group
 72:       lvname="/dev/XX"
 73:       lv_mount_point="/XX"
 74:       mount_status=`/usr/sbin/mount | /usr/bin/nawk -v lv=${lvname} 'lv==$1{flag=1; exit;} END{if(flag==1) print "mounted"; else print "not_mounted";}'`
 75:       if [ $mount_status = "not_mounted" ]
 76:       then
 77:          /usr/sbin/mount $lvname $lv_mount_point 2> /dev/null
 78:          if [ $? != 0 ]
 79:          then
 80:             retry_count=3
 81:             sleep_time=1
 82:             result_flag=1
 83: 
 84:             while [ $retry_count -gt 0 ]
 85:             do
 86:                /usr/sbin/mount $lvname $lv_mount_point > $err_log_path/$dev.mount 2>&1
 87:                if [ $? != 0 ]
 88:                then
 89:                   retry_count=`expr $retry_count - 1`
 90:                   /usr/bin/sleep $sleep_time
 91:                else
 92:                   /usr/bin/rm -f $err_log_path/$dev.mount
 93:                   result_flag=0
 94:                   break
 95:                fi
 96:             done
 97: 
 98:             if [ $result_flag != 0 ]
 99:             then
100:                mount_error=1
101:             fi
102:          fi
103:       fi
104: 
105: #      lvname="/dev/XX"
106: #      lv_mount_point="/XX"
107: #      mount_status=`/usr/sbin/mount | /usr/bin/nawk -v lv=${lvname} 'lv==$1{flag=1; exit;} END{if(flag==1) print "mounted"; else print "not_mounted";}'`
108: #      if [ $mount_status = "not_mounted" ]
109: #      then
110: #         /usr/sbin/mount $lvname $lv_mount_point 2>/dev/null
111: #         if [ $? != 0 ]
112: #         then
113: #            retry_count=3
114: #            sleep_time=1
115: #            result_flag=1
116: #
117: #            while [ $retry_count -gt 0 ]
118: #            do
119: #               /usr/sbin/mount $lvname $lv_mount_point > $err_log_path/$dev.mount 2>&1
120: #               if [ $? != 0 ]
121: #               then
122: #                  retry_count=`expr $retry_count - 1`
123: #                  /usr/bin/sleep $sleep_time
124: #               else
125: #                  rm -f $err_log_path/$dev.mount
126: #                  result_flag=0
127: #                  break
128: #               fi
129: #            done
130: #
131: #            if [ $result_flag != 0 ]
132: #            then
133: #               mount_error=1
134: #            fi
135: #         fi
136: #      fi
137: 
138:       if [ $mount_error != 0 ]
139:       then
140:          exit 11
141:       fi
142:    fi
143: fi
144: 
145: /usr/bin/rm -rf $post_file 2> /dev/null
146: exit 0

Replication Destination Volume Post-processing Sample Script (RepDst.post)

  1: #!/bin/sh
  2: 
  3: # AdvancedCopy Manager
  4: # All Rights Reserved, Copyright FUJITSU LIMITED, 2004-2007
  5: 
  6: #
  7: #   Post-processing of Replication(Destination) processing
  8: #
  9: #               Argument: $1 Device name of Destination disk
 10: #
 11: #       Error number
 12: #               2: Argument error
 13: #              11: mount error
 14: #              53: chdev error
 15: #              54: exportvg error
 16: #              56: recreatevg error
 17: #              52: chfs error
 18: 
 19: # Reconstruct volume group function.
 20: ReconstructVG ()
 21: {
 22: 
 23:    # delete PV temporally.
 24:    /usr/sbin/chdev -l $pvname -a pv=clear > /dev/null 2>&1
 25:    if [ $? != 0 ]
 26:    then
 27:       /usr/sbin/chdev -l $pvname -a pv=clear > $err_log_path/$dev.chdev 2>&1
 28:       if [ $? != 0 ]
 29:       then
 30:           return 53
 31:       else
 32:           /usr/bin/rm -f $err_log_path/$dev.chdev
 33:       fi
 34:    fi
 35: 
 36:    # export destination volume group
 37:    /usr/sbin/exportvg $dev > /dev/null 2>&1
 38:    if [ $? != 0 ]
 39:    then
 40:       /usr/sbin/exportvg $dev > $err_log_path/$dev.exportvg 2>&1
 41:       if [ $? != 0 ]
 42:       then
 43:           return 54
 44:       else
 45:           /usr/bin/rm -f $err_log_path/$dev.exportvg 
 46:       fi
 47:    fi
 48: 
 49:    # recreate destination volume group
 50:    prefix="/fs"
 51:    /usr/sbin/recreatevg -l $conv_file -L $prefix -y $dev $pvname > /dev/null 2>&1
 52:    if [ $? != 0 ]
 53:    then
 54:       /usr/sbin/recreatevg -l $conv_file -L $prefix -y $dev $pvname > $err_log_path/$dev.recreatevg 2>&1
 55:       if [ $? != 0 ]
 56:       then
 57:          return 56
 58:       else
 59:          /usr/bin/rm -f $err_log_path/$dev.recreatevg
 60:       fi
 61:    fi
 62:    
 63:    return 0
 64: }
 65: 
 66: # Mount Logical Volume function
 67: MountLV ()
 68: {
 69:    mount_status=`/usr/sbin/mount | /usr/bin/nawk -v lv=${lvname} 'lv==$1{flag=1; exit;} END{if(flag==1) print "mounted"; else print "not_mounted";}'`
 70:    if [ $mount_status = "not_mounted" ]
 71:    then
 72:       /usr/sbin/mount $lvname $dst_mount_point 2> /dev/null
 73:       if [ $? != 0 ]
 74:       then
 75:           retry_count=3
 76:           sleep_time=1
 77:           result_flag=1
 78: 
 79:           while [ $retry_count -gt 0 ]
 80:           do
 81:              /usr/sbin/mount $lvname $dst_mount_point > $err_log_path/$dev.mount 2>&1
 82:              if [ $? != 0 ]
 83:              then
 84:                 retry_count=`expr $retry_count - 1`
 85:                 /usr/bin/sleep $sleep_time
 86:              else
 87:                 /usr/bin/rm -f $err_log_path/$dev.mount
 88:                 result_flag=0
 89:                 break
 90:              fi
 91:           done
 92: 
 93:           if [ $result_flag != 0 ]
 94:           then
 95:              exit 11
 96:           fi
 97:       fi
 98:    fi
 99: }
100: 
101: # Change mount point function
102: ChangeMountPoint ()
103: {
104:    /usr/sbin/chfs -m $dst_mount_point $prefix$src_mount_point > /dev/null 2>&1
105:    if [ $? != 0 ]
106:    then
107:       /usr/sbin/chfs -m $dst_mount_point $prefix$dst_mount_point > /dev/null 2>&1
108:       if [ $? != 0 ]
109:       then
110:          /usr/sbin/chfs -m $dst_mount_point $prefix$dst_mount_point > $err_log_path/$dev.chfs 2>&1
111:          if [ $? != 0 ]
112:          then
113:             exit 52
114:          else
115:             /usr/bin/rm -f $err_log_path/$dev.chfs
116:          fi
117:       fi
118:    fi
119: }
120: 
121: ###############################
122: #
123: # RepDst.post Main process.
124: #
125: ###############################
126: 
127: # Argument check
128: case $# in
129: 1)
130:    ;;
131: *)
132:    exit 2
133:    ;;
134: esac
135: 
136: device=$1
137: 
138: # Determination of postprocessing file name
139: if [ "`echo $device | /usr/bin/grep "/dev/hdisk"`" != "" ]
140: then
141:    dev_type="lvm_pv"
142:    # /dev/hdisk? -> hdisk?
143:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
144: 
145: elif [ "`echo $device | /usr/bin/grep "/dev/vx/dmp/"`" != "" ]
146: then
147:    dev_type="vxvm_pv"
148:    # /dev/vx/dmp/device -> device
149:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $5 }'`"
150: 
151: elif [ "`echo $device | /usr/bin/grep "/dev/"`" != "" ]
152: then
153:    dev_type="lvm_vg"
154:    # /dev/VG_Name -> VG_Name
155:    dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
156: 
157: else
158:    # Other Volume
159:    exit 0
160: fi
161: post_file="/etc/opt/FJSVswsrp/"$SWSTGNODE"/data/DEFAULT/"$dev".dpre"
162: conv_file="/etc/opt/FJSVswsrp/"$SWSTGNODE"/data/DEFAULT/"$dev".tmp"
163: 
164: err_log_path="/var/opt/FJSVswsrp/"$SWSTGNODE"/log"
165: 
166: # Confirmation of postprocessing
167: if [ ! -r $post_file ]
168: then
169:         exit 0
170: fi
171: # When the Destination disk is a volume group #############################
172: if [ "$dev_type" = "lvm_vg" ]
173: then
174: 
175:    post="`/usr/bin/cat $post_file | /usr/bin/cut -d',' -f1`"
176:    vg_status="`/usr/bin/cat $post_file | /usr/bin/cut -d',' -f2`"
177: 
178:    if [ "$vg_status" = "varyon" ]
179:    then
180:       if [ "$device" = "/dev/vgXX" ]
181:       then
182:          pvname="hdiskXX"
183: 
184:          # decide conversion of LV name
185:          /usr/bin/rm -rf $conv_file 2> /dev/null
186:          echo "SrclvXXXX:DstlvXXXXX" >> $conv_file
187:          echo "DstlvXXXX:DstlvXXXXX" >> $conv_file
188: #         echo "SrclvXXXX:DstlvXXXXX" >> $conv_file
189: #         echo "DstlvXXXX:DstlvXXXXX" >> $conv_file
190: 
191:          # Reconstruct Volume Group
192:          ReconstructVG
193:          result=$?
194:          if [ $result != 0 ]
195:          then
196:             exit $result
197:          fi
198: 
199:          # delete tmpfile
200:          /usr/bin/rm -rf $conv_file 2> /dev/null
201:       fi
202:    fi
203: 
204:    if [ "$device" = "/dev/vgXX" ]
205:    then
206: 
207:       # decide new mount point
208:       lvname="/dev/XX"
209:       src_mount_point="/XX"
210:       dst_mount_point="/XX"
211: 
212:       if [ "$vg_status" = "varyon" ]
213:       then
214:          # Change mount point
215:          ChangeMountPoint
216:       fi
217: 
218:       if [ "$post" = "mount" ]
219:       then
220:          # Mount all logical volumes of the volume group
221:          MountLV
222:       fi
223: 
224: #      lvname="/dev/XX"
225: #      src_mount_point="/XX"
226: #      dst_mount_point="/XX"
227: #   
228: #      if [ "$vg_status" = "varyon" ]
229: #      then
230: #         # Change mount point
231: #         ChangeMountPoint
232: #      fi
233: #   
234: #      if [ "$post" = "mount" ]
235: #      then
236: #         # Mount all logical volumes of the volume group
237: #         MountLV
238: #      fi
239: 
240:    fi
241: fi
242: 
243: /usr/bin/rm -rf $post_file 2> /dev/null
244: exit 0
245: