Top
ETERNUS SF AdvancedCopy Manager V15.0 Operation Guide

A.2.1 Pre-processing of backup

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

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

A.2.1.1 Pre-processing script for backup

  1: #!/bin/sh
  2: 
  3: # AdvancedCopy Manager
  4: # Copyright FUJITSU LIMITED, 2002-2012
  5: 
  6: #
  7: #   Preprocessing of backup processing
  8: #
  9: #       Argument: $1 Device name of transaction disk
 10: #                 $2 Mount point of transaction disk
 11: #                 $3 Device name of backup disk
 12: #
 13: #  Error number
 14: #           2: Argument error
 15: #          10: umount error
 16: #          13: Illegal mount type (bind/stack mount)
 17: 
 18: 
 19: # Argument check
 20: case $# in
 21: 1)
 22:    ;;
 23: 2)
 24:    ;;
 25: 3)
 26:    ;;
 27: *)
 28:    exit 2
 29:    ;;
 30: esac
 31: 
 32: device="`echo $1`"
 33: mount_point="`echo $2`"
 34: bk_device="`echo $3`"
 35: 
 36: # Determination postprocessing file name
 37: 
 38: if [ "$SWSTGNODE" != "" ]
 39: then
 40: swstg_node="/`echo $SWSTGNODE`"
 41: else
 42: swstg_node=""
 43: fi
 44: 
 45: err_log_path="/var/opt/FJSVswsts"$swstg_node"/log"
 46: 
 47: if [ "`echo $device | /bin/grep "/dev/sd"`" != "" ]
 48: then
 49:    # /dev/sd? -> sd?
 50:    dev="`echo $device | /bin/sed "s/\/dev\///"`"
 51: elif [ "`echo $device | /bin/grep "/dev/vd"`" != "" ]
 52: then
 53:    # /dev/vd? -> vd?
 54:    dev="`echo $device | /bin/sed "s/\/dev\///"`"
 55: elif [ "`echo $device | /bin/grep "/dev/FJSV"`" != "" ]
 56: then
 57:    # /dev/FJSVmphd/dsk/mplb?s? -> mplb?s?
 58:    # /dev/FJSVmphd/dsk/mphd?s? -> mphd?s?
 59:    dev="`echo $device | /bin/cut -d/ -f5`"
 60: elif [ "`echo $device | /bin/grep "/dev/sfdsk/"`" != "" ]
 61: then
 62:    if [ "`echo $device | /bin/grep ":"`" != ""   ]
 63:    then
 64:            devnam="`echo $device | /bin/cut -d: -f2-`"
 65:            # /dev/sfdsk/class/dsk/volume:sd? -> class_volume_sd?
 66:            dev="`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`"
 67:            dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`"
 68:            dev="`echo $dev | /bin/sed "s/:/_/"`"
 69:            device="`echo $device | /bin/cut -d: -f1`"
 70:            if [ "`echo $devnam | /bin/grep "/dev/disk/by-id/"`" != "" ]
 71:            then
 72:                    # /dev/sfdsk/class/dsk/volume:/dev/disk/by-id/<device> -> class_volume__by_id_<device>
 73:                    dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-id\//_by-id_/"`"
 74:            elif [ "`echo $devnam | /bin/grep "/dev/disk/by-path/"`" != "" ]
 75:            then
 76:                    # /dev/sfdsk/class/dsk/volume:/dev/disk/by-path/<device> -> class_volume__by_path_<device>
 77:                    dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-path\//_by-path_/"`"
 78:            fi
 79:    else
 80:            # /dev/sfdsk/class/dsk/volume -> _gds_class_volume
 81:            dev="_gds_`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`"
 82:            dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`"
 83:    fi
 84: elif [ "`echo $device | /bin/grep "/dev/vx/dmp/"`" != "" ]
 85: then
 86:    # /dev/vx/dmp/device -> _vx_pv_device
 87:    dev="_vx_pv_`echo $device | /bin/sed "s/\/dev\/vx\/dmp\///"`"
 88: elif [ "`echo $device | /bin/grep "/dev/mapper/"`" != "" ]
 89: then
 90:    # "/dev/mapper/<device>" -> "_mapper_<device>"
 91:    dev="_mapper_`echo $device | /bin/sed "s/\/dev\/mapper\///"`"
 92: elif [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ]
 93: then
 94:    # "/dev/disk/by-id/<device>" -> "_by-id_<device>"
 95:    dev="_by-id_`echo $device | /bin/sed "s/\/dev\/disk\/by-id\///"`"
 96: elif [ "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ]
 97: then
 98:    # "/dev/disk/by-path/<device>" -> "_by-path_<device>"
 99:    dev="_by-path_`echo $device | /bin/sed "s/\/dev\/disk\/by-path\///"`"
100: else
101:    exit 0
102: fi
103: post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
104: fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype"
105: bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd"
106: 
107: if [ "$mount_point" != "" ]
108: then
109: 
110: # When device cannot be unmounted
111: #
112: #  if [ "$device" = "/dev/sdX" -o "$device" = "/dev/sdY" ]
113: #  then
114: #          if [ "$bk_device" != "" ]
115: #          then
116: #                  echo $bk_device > $bd_file
117: #          fi
118: #          /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file
119: #          /bin/sync
120: #          /bin/sync
121: #          /bin/sync
122: #          echo "fsck" > $post_file
123: 
124: # When device can be unmounted
125: #
126: #  else
127:            if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 2|/bin/grep "^$mount_point\$"|/usr/bin/wc -w` != 1 ]; then
128:                    # stack mount (multi device on $mount_point)
129:                    /bin/mount  > $err_log_path/$dev.umount 2>&1
130:                    exit 13
131:            fi
132:            if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 1|/bin/grep "^$device\$"|/usr/bin/wc -w` != 1 ]; then
133:                    cdevice="/dev/`/usr/bin/readlink $device | /bin/sed "s/..\/..\///"`"
134:                    if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 1|/bin/grep "^$cdevice\$"|/usr/bin/wc -w` != 1 ]; then
135:                           # bind mount (device has multi mount point)
136:                           /bin/mount  > $err_log_path/$dev.umount 2>&1
137:                           exit 13
138:                    fi
139:            fi
140: 
141:            /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file
142:            /bin/umount $mount_point 2>/dev/null
143:            if [ $? != 0 ]
144:            then
145:                    retry_count=3
146:                    sleep_time=1
147:                    result_flag=1
148: 
149:                    while [ $retry_count -gt 0 ]
150:                    do
151:                            /bin/umount $mount_point > $err_log_path/$dev.umount 2>&1
152:                            if [ $? != 0 ]
153:                            then
154:                                    retry_count=`expr $retry_count - 1`
155:                                    /bin/sleep $sleep_time
156:                            else
157:                                    /bin/rm -f $err_log_path/$dev.umount
158:                                    result_flag=0
159:                                    break
160:                            fi
161:                    done
162: 
163:                    if [ $result_flag != 0 ]
164:                    then
165:                            /sbin/fuser -vum $mount_point> $err_log_path/$dev.fuser 2>&1 
166:                            /bin/ps -ef > $err_log_path/$dev.ps 2>&1 
167: 
168:                            exit 10
169:                    fi
170:                    fi
171:                    echo "mount" > $post_file
172: 
173: #  fi
174: 
175: # When device was not mounted
176: #
177: else
178:   echo "none" > $post_file
179: fi
180: 
181: exit 0