ETERNUS SF AdvancedCopy Manager 運用手引書 13.2 -Linux-
目次 索引 前ページ次ページ

付録A バックアップ/リストアの前後処理> A.2 バックアップの前後処理

A.2.2 バックアップ実行時の後処理

バックアップ実行時の後処理のシェルスクリプト名は、以下のとおりです。

バックアップ時の後処理シェルスクリプト

  1:   #!/bin/sh
  2:   
  3:   # AdvancedCopy Manager
  4:   # All Rights Reserved, Copyright FUJITSU LIMITED, 2002-2007
  5:   
  6:   #
  7:   #   Postprocessing of backup processing
  8:   #
  9:   #Argument: $1 Device name of transaction disk
 10:  #      $2 Mount point of transaction disk
 11:  #
 12:  #Error number
 13:  # 2: Argument error
 14:  #11: mount error
 15:  #12: fsck error
 16:  
 17:  # Argument check
 18:  case $# in
 19:  1)
 20:  ;;
 21:  2)
 22:  ;;
 23:  *)
 24:  exit 2
 25:  ;;
 26:  esac
 27:  
 28:  device="`echo $1`"
 29:  mount_point="`echo $2`"
 30:  
 31:  # Determination of postprocessing file name
 32:  
 33:  if [ "$SWSTGNODE" != "" ]
 34:  then
 35:  swstg_node="/`echo $SWSTGNODE`"
 36:  else
 37:  swstg_node=""
 38:  fi
 39:  
 40:  err_log_path="/var/opt/FJSVswsts"$swstg_node"/log"
 41:  
 42:  if [ "`echo $device | /bin/grep "/dev/sd"`" != "" ]
 43:  then
 44:  # /dev/sd? -> sd?
 45:  dev="`echo $device | /bin/sed "s/\/dev\///"`"
 46:  elif [ "`echo $device | /bin/grep "/dev/FJSV"`" != "" ]
 47:  then
 48:  # /dev/FJSVmphd/dsk/mplb?s? -> mplb?s?
 49:  # /dev/FJSVmphd/dsk/mphd?s? -> mphd?s?
 50:  dev="`echo $device | /bin/cut -d/ -f5`"
 51:  elif [ "`echo $device | /bin/grep "/dev/sfdsk/"`" != "" ]
 52:  then
 53:  if [ "`echo $device | /bin/grep ":"`" != ""   ]
 54:  then
 55:  # /dev/sfdsk/class/dsk/volume:sd? -> class_volume_sd?
 56:  dev="`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`"
 57:  dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`"
 58:  dev="`echo $dev | /bin/sed "s/:/_/"`"
 59:  device="`echo $device | /bin/cut -d: -f1`"
 60:  else
 61:  # /dev/sfdsk/class/dsk/volume -> _gds_class_volume
 62:  dev="_gds_`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`"
 63:  dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`"
 64:  fi
 65:  elif [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ]
 66:  then
 67:  # "/dev/disk/by-id/<device>" -> "_by-id_<device>"
 68:  dev="_by-id_`echo $device | /bin/sed "s/\/dev\/disk\/by-id\///"`"
 69:  elif [ "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ]
 70:  then
 71:  # "/dev/disk/by-path/<device>" -> "_by-path_<device>"
 72:  dev="_by-path_`echo $device | /bin/sed "s/\/dev\/disk\/by-path\///"`"
 73:  else
 74:  exit 0
 75:  fi
 76:  post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
 77:  fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype"
 78:  bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd"
 79:  
 80:  # Confirmation of postprocessing
 81:  if [ ! -r $post_file ]
 82:  then
 83:  exit 0
 84:  fi
 85:  post="`/bin/cat $post_file`"
 86:  
 87:  # Confirmation of FStype
 88:  if [ ! -r $fstype_file ]
 89:  then
 90:  fs=""
 91:  else
 92:  fs="`/bin/cat $fstype_file`"
 93:  fi
 94:  
 95:  # No processing
 96:  if [ "$post" = "none" ]
 97:  then
 98:  /bin/rm -rf $post_file 2> /dev/null
 99:  /bin/rm -rf $fstype_file 2> /dev/null
100: exit 0
101: fi
102: 
103: # mount processing
104: if [ "$post" = "mount" ]
105: then
106: if [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" \
107: -o "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ]
108: then
109: cdevice="/dev/`/usr/bin/readlink $device | /bin/sed "s/..\/..\///"`"
110: Result="`/bin/df -l | /bin/grep "$cdevice " | /bin/awk 'END {print NR}'`"
111: else
112: Result="`/bin/df -l | /bin/grep "$device " | /bin/awk 'END {print NR}'`"
113: fi
114:   if [ "$Result" != "1" ]
115: then
116: if [ ! -r $fstype_file ]
117: then
118: /bin/mount $device $mount_point 2> /dev/null
119: else
120: Result1="`echo $fs | /bin/awk 'END {print NR}'`"
121:                         if [ "$Result1" != "1" ]
122: then
123: /bin/mount $device $mount_point 2> /dev/null
124: else
125: /bin/mount -t $fs $device $mount_point 2> /dev/null
126: fi
127: fi
128: if [ $? != 0 ]
129: then
130: retry_count=3
131: sleep_time=1
132: result_flag=1
133: 
134: while [ $retry_count -gt 0 ]
135: do
136: if [ ! -r $fstype_file ]
137: then
138: /bin/mount $device $mount_point > $err_log_path/$dev.mount 2>&1
139: else
140: Result1="`echo $fs | /bin/awk 'END {print NR}'`"
141: if [ "$Result1" != "1" ]
142: then
143: /bin/mount $device $mount_point > $err_log_path/$dev.mount 2>&1
144: else
145: /bin/mount -t $fs $device $mount_point > $err_log_path/$dev.mount 2>&1
146: fi
147: fi
148: if [ $? != 0 ]
149: then
150: retry_count=`expr $retry_count - 1`
151: /bin/sleep $sleep_time
152: else
153: /bin/rm -f $err_log_path/$dev.mount
154: result_flag=0
155: break
156: fi
157: done
158: 
159: if [ $result_flag != 0 ]
160: then
161: exit 11
162: fi
163: fi
164: fi
165: /bin/rm -rf $post_file 2> /dev/null
166: /bin/rm -rf $fstype_file 2> /dev/null
167: exit 0
168: fi
169: 
170: # fsck processing
171: if [ "$post" = "fsck" ]
172: then
173: if [ -r $bd_file ]
174: then
175: bk_device="`/bin/cat $bd_file`"
176: fsck_dev="`echo $bk_device `"
177: if [ ! -r $fstype_file ]
178: then
179: /sbin/fsck -c $fsck_dev > /dev/null 2>&1
180: else
181: if [ "$fs" = "" ]
182: then
183: /sbin/fsck -c $fsck_dev > /dev/null 2>&1
184: else
185: if [ "$fs" = "sfxfs" ]
186: then
187: /sbin/sfxadm $fsck_dev > /dev/null 2>&1
188: /sbin/fsck -p -t $fs $fsck_dev > /dev/null 2>&1
189: else
190: /sbin/fsck -p -t $fs $fsck_dev > /dev/null 2>&1
191: fi
192: fi
193: fi
194: if [ $? != 0 ]
195: then
196: if [ "$fs" = "" ]
197: then
198: result="`/sbin/fsck -p $fsck_dev `"
199: else
200: result="`/sbin/fsck -p -t $fs $fsck_dev `"
201: fi
202: fsck_rc=$?
203: if [ $fsck_rc != 0 ] && [ $fsck_rc != 1 ]
204: then
205: echo "$result" > $err_log_path/$dev.fsck
206: exit 12
207: fi
208: fi
209: fi
210: /bin/rm -rf $post_file 2> /dev/null
211: /bin/rm -rf $fstype_file 2> /dev/null
212: /bin/rm -rf $bd_file 2> /dev/null
213: exit 0
214: fi
215: 
216: exit 0

目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 2000-2008