ページのトップに戻る
ETERNUS SFAdvancedCopy Manager 13.4 運用手引書テープバックアップ連携編

A.4.3 Linuxのテープコピー実行時の前処理

テープコピー実行時の前処理のシェルスクリプト名は、以下のとおりです。

シェルスクリプトの内容は、以下のとおりです。

  1:   #!/bin/sh
  2:   
  3:   # AdvancedCopy Manager
  4:   # All Rights Reserved, Copyright FUJITSU LIMITED, 2005-2007
  5:   
  6:   #
  7:   #   Preprocessing of tape copy processing
  8:   #
  9:   #       Argument: $1 Device name of backup disk
 10:  #                 $2 Reserve
 11:  #
 12:  #	Error number
 13:  #		 2: Argument error
 14:  #		10: umount error
 15:  #		13: Illegal mount type (bind/stack mount)
 16:  
 17:  
 18:  # Argument check
 19:  case $# in
 20:  1)
 21:  	;;
 22:  2)
 23:  	;;
 24:  *)
 25:  	exit 2
 26:  	;;
 27:  esac
 28:  
 29:  device="`echo $1`"
 30:  
 31:  # Determination 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:  	# /dev/sfdsk/class/dsk/volume -> _gds_class_volume
 54:  	dev="_gds_`echo $device | /bin/sed "s/¥/dev¥/sfdsk¥///"`"
 55:  	dev="`echo $dev | /bin/sed "s/¥/dsk¥//_/"`"
 56:  elif [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ]
 57:  then
 58:  	# "/dev/disk/by-id/<device>" -> "_by-id_<device>"
 59:  	dev="_by-id_`echo $device | /bin/sed "s/¥/dev¥/disk¥/by-id¥///"`"
 60:  elif [ "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ]
 61:  then
 62:  	# "/dev/disk/by-path/<device>" -> "_by-path_<device>"
 63:  	dev="_by-path_`echo $device | /bin/sed "s/¥/dev¥/disk¥/by-path¥///"`"
 64:  else
 65:  	exit 0
 66:  fi
 67:  post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
 68:  
 69:  if [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ¥
 70:  	-o "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ]
 71:  then
 72:  	cdevice="/dev/`/usr/bin/readlink $device | /bin/sed "s/..¥/..¥///"`"
 73:  	cur_mount_point=`/bin/mount | grep "$cdevice " | cut -f3 -d' '`
 74:  else
 75:  	cur_mount_point=`/bin/mount | grep "$device " | cut -f3 -d' '`
 76:  fi
 77:  if [ "$cur_mount_point" != "" ]
 78:  then
 79:  
 80:  	if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 2|/bin/grep "^$cur_mount_point¥$"|/usr/bin/wc -w` != 1 ]; then
 81:  		# stack mount (multi device on $cur_mount_point)
 82:  		/bin/mount  > $err_log_path/$dev.umount 2>&1
 83:  		exit 13
 84:  	fi
 85:  	if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 1|/bin/grep "^$device¥$"|/usr/bin/wc -w` != 1 ]; then
 86:  		# bind mount (device has multi mount point)
 87:  		/bin/mount  > $err_log_path/$dev.umount 2>&1
 88:  		exit 13
 89:  	fi
 90:  
 91:  	/bin/umount $cur_mount_point 2>/dev/null
 92:  	if [ $? != 0 ]
 93:  	then
 94:  		retry_count=3
 95:  		sleep_time=1
 96:  		result_flag=1
 97:  
 98:  		while [ $retry_count -gt 0 ]
 99:  		do
100: 			/bin/umount $cur_mount_point > $err_log_path/$dev.umount 2>&1
101: 			if [ $? != 0 ]
102: 			then
103: 				retry_count=`expr $retry_count - 1`
104: 				/bin/sleep $sleep_time
105: 			else
106: 				/bin/rm -f $err_log_path/$dev.umount
107: 				result_flag=0
108: 				break
109: 			fi
110: 		done
111: 
112: 		if [ $result_flag != 0 ]
113: 		then
114: 			/sbin/fuser -vu $cur_mount_point> $err_log_path/$dev.fuser 2>&1 
115: 			/bin/ps -ef > $err_log_path/$dev.ps 2>&1 
116: 
117: 			exit 10
118: 		fi
119: 	fi
120: 	echo "mount" > $post_file
121: 
122: # When device was not mounted
123: #
124: else
125: 	echo "none" > $post_file
126: fi
127: 
128: exit 0