バックアップ実行時の前処理のシェルスクリプト名は、以下のとおりです。
クラスタ運用でない場合
/etc/opt/FJSVswsts/sh/OpcBackup.pre |
クラスタ運用の場合
/etc/opt/FJSVswsts/logicalNodeName/sh/OpcBackup.pre |
バックアップ時の前処理シェルスクリプト(OpcBackup.pre)
Red Hat Enterprise Linux 8、Red Hat Enterprise Linux 7、またはRed Hat Enterprise Linux 6の場合
1: #!/bin/sh 2: 3: # AdvancedCopy Manager 4: # Copyright FUJITSU LIMITED, 2002-2021 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: # 14: fsfreeze error 18: 19: 20: # Argument check 21: case $# in 22: 1) 23: ;; 24: 2) 25: ;; 26: 3) 27: ;; 28: *) 29: exit 2 30: ;; 31: esac 32: 33: device="`echo $1`" 34: mount_point="`echo $2`" 35: bk_device="`echo $3`" 36: cyclemax=3 37: bindstack_cyclenumfile="bindstack.cyclenum" 38: unmount_cyclenumfile="unmount.cyclenum" 39: 40: # Determination postprocessing file name 41: 42: if [ "$SWSTGNODE" != "" ] 43: then 44: swstg_node="/`echo $SWSTGNODE`" 45: else 46: swstg_node="" 47: fi 48: 49: err_log_path="/var/opt/FJSVswsts"$swstg_node"/log" 50: 51: if [ "`echo $device | /bin/grep "/dev/sd"`" != "" ] 52: then 53: # /dev/sd? -> sd? 54: dev="`echo $device | /bin/sed "s/\/dev\///"`" 55: elif [ "`echo $device | /bin/grep "/dev/vd"`" != "" ] 56: then 57: # /dev/vd? -> vd? 58: dev="`echo $device | /bin/sed "s/\/dev\///"`" 59: elif [ "`echo $device | /bin/grep "/dev/FJSV"`" != "" ] 60: then 61: # /dev/FJSVmphd/dsk/mplb?s? -> mplb?s? 62: # /dev/FJSVmphd/dsk/mphd?s? -> mphd?s? 63: dev="`echo $device | /bin/cut -d/ -f5`" 64: elif [ "`echo $device | /bin/grep "/dev/sfdsk/"`" != "" ] 65: then 66: if [ "`echo $device | /bin/grep ":"`" != "" ] 67: then 68: devnam="`echo $device | /bin/cut -d: -f2-`" 69: # /dev/sfdsk/class/dsk/volume:sd? -> class_volume_sd? 70: dev="`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`" 71: dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`" 72: dev="`echo $dev | /bin/sed "s/:/_/"`" 73: device="`echo $device | /bin/cut -d: -f1`" 74: if [ "`echo $devnam | /bin/grep "/dev/disk/by-id/"`" != "" ] 75: then 76: # /dev/sfdsk/class/dsk/volume:/dev/disk/by-id/<device> -> class_volume__by_id_<device> 77: dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-id\//_by-id_/"`" 78: elif [ "`echo $devnam | /bin/grep "/dev/disk/by-path/"`" != "" ] 79: then 80: # /dev/sfdsk/class/dsk/volume:/dev/disk/by-path/<device> -> class_volume__by_path_<device> 81: dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-path\//_by-path_/"`" 82: fi 83: else 84: # /dev/sfdsk/class/dsk/volume -> _gds_class_volume 85: dev="_gds_`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`" 86: dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`" 87: fi 88: elif [ "`echo $device | /bin/grep "/dev/vx/dmp/"`" != "" ] 89: then 90: # /dev/vx/dmp/device -> _vx_pv_device 91: dev="_vx_pv_`echo $device | /bin/sed "s/\/dev\/vx\/dmp\///"`" 92: elif [ "`echo $device | /bin/grep "/dev/mapper/"`" != "" ] 93: then 94: # "/dev/mapper/<device>" -> "_mapper_<device>" 95: dev="_mapper_`echo $device | /bin/sed "s/\/dev\/mapper\///"`" 96: elif [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ] 97: then 98: # "/dev/disk/by-id/<device>" -> "_by-id_<device>" 99: dev="_by-id_`echo $device | /bin/sed "s/\/dev\/disk\/by-id\///"`" 100: elif [ "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ] 101: then 102: # "/dev/disk/by-path/<device>" -> "_by-path_<device>" 103: dev="_by-path_`echo $device | /bin/sed "s/\/dev\/disk\/by-path\///"`" 104: else 105: exit 0 106: fi 107: post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre" 108: fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype" 109: bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd" 110: 111: if [ "$mount_point" != "" ] 112: then 113: 114: proc="" 115: # When device cannot be unmounted (sync) 116: # 117: # if [ "$device" = "/dev/sdX" -o "$device" = "/dev/sdY" ] 118: # then 119: # proc="sync" 120: # if [ "$bk_device" != "" ] 121: # then 122: # echo $bk_device > $bd_file 123: # fi 124: # /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file 125: # /bin/sync 126: # /bin/sync 127: # /bin/sync 128: # echo "fsck" > $post_file 129: # fi 130: 131: # When device cannot be unmounted (fsfreeze) 132: # if [ "$device" = "/dev/sdX" -o "$device" = "/dev/sdY" ] 133: # then 134: # proc="fsfreeze" 135: # result="`/sbin/fsfreeze -f $mount_point 2>&1 `" 136: # if [ $? != 0 ] 137: # then 138: # echo "$result" > $err_log_path/$dev.fsfreeze 139: # exit 14 140: # fi 141: # echo "fsfreeze" > $post_file 142: # fi 143: 144: # When device can be unmounted 145: # 146: # if [ "$proc" = "" ];then 147: if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 2|/bin/grep "^$mount_point\$"|/usr/bin/wc -w` != 1 ]; then 148: # stack mount (multi device on $mount_point) 149: if [ -f $err_log_path/$bindstack_cyclenumfile ] 150: then 151: cyclenum=`/bin/cut -c 1 $err_log_path/$bindstack_cyclenumfile` 152: cyclenum=`expr $cyclenum + 1 2>/dev/null` 153: if [ $? != 0 ]; then 154: cyclenum='1' 155: fi 156: if [ $cyclenum -gt $cyclemax ]; then 157: cyclenum='1' 158: fi 159: else 160: cyclenum='1' 161: fi 162: echo $cyclenum > $err_log_path/$bindstack_cyclenumfile 163: 164: echo `date '+%Y-%m-%d %T'` > $err_log_path/"$dev"_$cyclenum.mounts 165: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 166: echo mount_point = $mount_point >> $err_log_path/"$dev"_$cyclenum.mounts 167: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 168: /bin/cat /proc/mounts >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 169: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 170: /bin/mount >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 171: exit 13 172: fi 173: if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 1|/bin/grep "^$device\$"|/usr/bin/wc -w` != 1 ]; then 174: cdevice="/dev/`/usr/bin/readlink $device | /bin/sed "s/..\/..\///"`" 175: if [ `/bin/cat /proc/mounts |/bin/cut -d' ' -f 1|/bin/grep "^$cdevice\$"|/usr/bin/wc -w` != 1 ]; then 176: # bind mount (device has multi mount point) 177: if [ -f $err_log_path/$bindstack_cyclenumfile ] 178: then 179: cyclenum=`/bin/cut -c 1 $err_log_path/$bindstack_cyclenumfile` 180: cyclenum=`expr $cyclenum + 1 2>/dev/null` 181: if [ $? != 0 ]; then 182: cyclenum='1' 183: fi 184: if [ $cyclenum -gt $cyclemax ]; then 185: cyclenum='1' 186: fi 187: else 188: cyclenum='1' 189: fi 190: echo $cyclenum > $err_log_path/$bindstack_cyclenumfile 191: 192: echo `date '+%Y-%m-%d %T'` > $err_log_path/"$dev"_$cyclenum.mounts 193: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 194: echo mount_point = $mount_point >> $err_log_path/"$dev"_$cyclenum.mounts 195: echo cdevice = $cdevice >> $err_log_path/"$dev"_$cyclenum.mounts 196: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 197: /bin/cat /proc/mounts >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 198: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 199: /bin/mount >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 200: exit 13 201: fi 202: fi 203: 204: /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file 205: /bin/umount $mount_point 2>/dev/null 206: if [ $? != 0 ] 207: then 208: retry_count=3 209: retry_def=$retry_count 210: sleep_time=1 211: result_flag=1 212: 213: while [ $retry_count -gt 0 ] 214: do 215: /bin/umount $mount_point > $err_log_path/$dev.umount 2>&1 216: if [ $? != 0 ] 217: then 218: if [ $retry_count -eq $retry_def ] 219: then 220: if [ -f $err_log_path/$unmount_cyclenumfile ] 221: then 222: cyclenum=`/bin/cut -c 1 $err_log_path/$unmount_cyclenumfile` 223: cyclenum=`expr $cyclenum + 1 2>/dev/null` 224: if [ $? != 0 ]; then 225: cyclenum='1' 226: fi 227: if [ $cyclenum -gt $cyclemax ]; then 228: cyclenum='1' 229: fi 230: else 231: cyclenum='1' 232: fi 233: echo $cyclenum > $err_log_path/$unmount_cyclenumfile 234: : > $err_log_path/"$dev"_$cyclenum.umount 235: : > $err_log_path/"$dev"_$cyclenum.fuser 236: : > $err_log_path/"$dev"_$cyclenum.ps 237: fi 238: 239: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.umount 240: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.fuser 241: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.ps 242: /bin/cat $err_log_path/$dev.umount >> $err_log_path/"$dev"_$cyclenum.umount 2>&1 243: /sbin/fuser -vum $mount_point >> $err_log_path/"$dev"_$cyclenum.fuser 2>&1 244: /bin/ps -ef >> $err_log_path/"$dev"_$cyclenum.ps 2>&1 245: echo "" >> $err_log_path/"$dev"_$cyclenum.umount 246: echo "" >> $err_log_path/"$dev"_$cyclenum.fuser 247: echo "" >> $err_log_path/"$dev"_$cyclenum.ps 248: 249: retry_count=`expr $retry_count - 1` 250: /bin/sleep $sleep_time 251: else 252: /bin/rm -f $err_log_path/$dev.umount 253: result_flag=0 254: break 255: fi 256: done 257: 258: if [ $result_flag != 0 ] 259: then 260: exit 10 261: fi 262: fi 263: echo "mount" > $post_file 264: 265: # fi 266: 267: # When device was not mounted 268: # 269: else 270: echo "none" > $post_file 271: fi 272: 273: exit 0
SUSE Linux Enterprise Server 15またはSUSE Linux Enterprise Server 12の場合
1: #!/bin/sh 2: 3: # AdvancedCopy Manager 4: # All Rights Reserved, Copyright FUJITSU LIMITED, 2002-2021 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: cyclemax=3 36: bindstack_cyclenumfile="bindstack.cyclenum" 37: unmount_cyclenumfile="unmount.cyclenum" 38: 39: # Determination postprocessing file name 40: 41: if [ "$SWSTGNODE" != "" ] 42: then 43: swstg_node="/`echo $SWSTGNODE`" 44: else 45: swstg_node="" 46: fi 47: 48: err_log_path="/var/opt/FJSVswsts"$swstg_node"/log" 49: 50: if [ "`echo $device | /bin/grep "/dev/sd"`" != "" ] 51: then 52: # /dev/sd? -> sd? 53: dev="`echo $device | /bin/sed "s/\/dev\///"`" 54: elif [ "`echo $device | /bin/grep "/dev/FJSV"`" != "" ] 55: then 56: # /dev/FJSVmphd/dsk/mplb?s? -> mplb?s? 57: # /dev/FJSVmphd/dsk/mphd?s? -> mphd?s? 58: dev="`echo $device | /usr/bin/cut -d/ -f5`" 59: elif [ "`echo $device | /bin/grep "/dev/sfdsk/"`" != "" ] 60: then 61: if [ "`echo $device | /bin/grep ":"`" != "" ] 62: then 63: devnam="`echo $device | /usr/bin/cut -d: -f2-`" 64: # /dev/sfdsk/class/dsk/volume:sd? -> class_volume_sd? 65: dev="`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`" 66: dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`" 67: dev="`echo $dev | /bin/sed "s/:/_/"`" 68: device="`echo $device | /usr/bin/cut -d: -f1`" 69: if [ "`echo $devnam | /bin/grep "/dev/disk/by-id/"`" != "" ] 70: then 71: # /dev/sfdsk/class/dsk/volume:/dev/disk/by-id/<device> -> class_volume__by_id_<device> 72: dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-id\//_by-id_/"`" 73: elif [ "`echo $devnam | /bin/grep "/dev/disk/by-path/"`" != "" ] 74: then 75: # /dev/sfdsk/class/dsk/volume:/dev/disk/by-path/<device> -> class_volume__by_path_<device> 76: dev="`echo $dev | /bin/sed "s/\/dev\/disk\/by-path\//_by-path_/"`" 77: fi 78: else 79: # /dev/sfdsk/class/dsk/volume -> _gds_class_volume 80: dev="_gds_`echo $device | /bin/sed "s/\/dev\/sfdsk\///"`" 81: dev="`echo $dev | /bin/sed "s/\/dsk\//_/"`" 82: fi 83: elif [ "`echo $device | /bin/grep "/dev/vx/dmp/"`" != "" ] 84: then 85: # /dev/vx/dmp/device -> _vx_pv_device 86: dev="_vx_pv_`echo $device | /bin/sed "s/\/dev\/vx\/dmp\///"`" 87: elif [ "`echo $device | /bin/grep "/dev/mapper/"`" != "" ] 88: then 89: # "/dev/mapper/<device>" -> "_mapper_<device>" 90: dev="_mapper_`echo $device | /bin/sed "s/\/dev\/mapper\///"`" 91: elif [ "`echo $device | /bin/grep "/dev/disk/by-id/"`" != "" ] 92: then 93: # "/dev/disk/by-id/<device>" -> "_by-id_<device>" 94: dev="_by-id_`echo $device | /bin/sed "s/\/dev\/disk\/by-id\///"`" 95: elif [ "`echo $device | /bin/grep "/dev/disk/by-path/"`" != "" ] 96: then 97: # "/dev/disk/by-path/<device>" -> "_by-path_<device>" 98: dev="_by-path_`echo $device | /bin/sed "s/\/dev\/disk\/by-path\///"`" 99: else 100: exit 0 101: fi 102: post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre" 103: fstype_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".fstype" 104: bd_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".bd" 105: 106: if [ "$mount_point" != "" ] 107: then 108: 109: # When device cannot be unmounted 110: # 111: # if [ "$device" = "/dev/sdX" -o "$device" = "/dev/sdY" ] 112: # then 113: # if [ "$bk_device" != "" ] 114: # then 115: # echo $bk_device > $bd_file 116: # fi 117: # /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file 118: # /bin/sync 119: # /bin/sync 120: # /bin/sync 121: # echo "fsck" > $post_file 122: 123: # When device can be unmounted 124: # 125: # else 126: if [ `/bin/cat /proc/mounts | /usr/bin/cut -d' ' -f 2|/bin/grep "^$mount_point\$"|/usr/bin/wc -w` != 1 ]; then 127: # stack mount (multi device on $mount_point) 128: if [ -f $err_log_path/$bindstack_cyclenumfile ] 129: then 130: cyclenum=`/usr/bin/cut -c 1 $err_log_path/$bindstack_cyclenumfile` 131: cyclenum=`expr $cyclenum + 1 2>/dev/null` 132: if [ $? != 0 ]; then 133: cyclenum='1' 134: fi 135: if [ $cyclenum -gt $cyclemax ]; then 136: cyclenum='1' 137: fi 138: else 139: cyclenum='1' 140: fi 141: echo $cyclenum > $err_log_path/$bindstack_cyclenumfile 142: 143: echo `date '+%Y-%m-%d %T'` > $err_log_path/"$dev"_$cyclenum.mounts 144: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 145: echo mount_point = $mount_point >> $err_log_path/"$dev"_$cyclenum.mounts 146: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 147: /bin/cat /proc/mounts >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 148: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 149: /bin/mount >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 150: exit 13 151: fi 152: if [ `/bin/cat /proc/mounts | /usr/bin/cut -d' ' -f 1|/bin/grep "^$device\$"|/usr/bin/wc -w` != 1 ]; then 153: cdevice="/dev/`/usr/bin/readlink $device | /bin/sed "s/..\/..\///"`" 154: if [ `/bin/cat /proc/mounts | /usr/bin/cut -d' ' -f 1|/bin/grep "^$cdevice\$"|/usr/bin/wc -w` != 1 ]; then 155: if [ -f $err_log_path/$bindstack_cyclenumfile ] 156: then 157: cyclenum=`/usr/bin/cut -c 1 $err_log_path/$bindstack_cyclenumfile` 158: cyclenum=`expr $cyclenum + 1 2>/dev/null` 159: if [ $? != 0 ]; then 160: cyclenum='1' 161: fi 162: if [ $cyclenum -gt $cyclemax ]; then 163: cyclenum='1' 164: fi 165: else 166: cyclenum='1' 167: fi 168: echo $cyclenum > $err_log_path/$bindstack_cyclenumfile 169: 170: echo `date '+%Y-%m-%d %T'` > $err_log_path/"$dev"_$cyclenum.mounts 171: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 172: echo mount_point = $mount_point >> $err_log_path/"$dev"_$cyclenum.mounts 173: echo cdevice = $cdevice >> $err_log_path/"$dev"_$cyclenum.mounts 174: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 175: /bin/cat /proc/mounts >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 176: echo "" >> $err_log_path/"$dev"_$cyclenum.mounts 177: /bin/mount >> $err_log_path/"$dev"_$cyclenum.mounts 2>&1 178: exit 13 179: fi 180: fi 181: 182: /bin/awk "\$2==\"$mount_point\" {print \$3}" /proc/mounts > $fstype_file 183: /bin/umount $mount_point 2>/dev/null 184: if [ $? != 0 ] 185: then 186: retry_count=3 187: retry_def=$retry_count 188: sleep_time=1 189: result_flag=1 190: 191: while [ $retry_count -gt 0 ] 192: do 193: /bin/umount $mount_point > $err_log_path/$dev.umount 2>&1 194: if [ $? != 0 ] 195: then 196: if [ $retry_count -eq $retry_def ] 197: then 198: if [ -f $err_log_path/$unmount_cyclenumfile ] 199: then 200: cyclenum=`/usr/bin/cut -c 1 $err_log_path/$unmount_cyclenumfile` 201: cyclenum=`expr $cyclenum + 1 2>/dev/null` 202: if [ $? != 0 ]; then 203: cyclenum='1' 204: fi 205: if [ $cyclenum -gt $cyclemax ]; then 206: cyclenum='1' 207: fi 208: else 209: cyclenum='1' 210: fi 211: echo $cyclenum > $err_log_path/$unmount_cyclenumfile 212: : > $err_log_path/"$dev"_$cyclenum.umount 213: : > $err_log_path/"$dev"_$cyclenum.fuser 214: : > $err_log_path/"$dev"_$cyclenum.ps 215: fi 216: 217: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.umount 218: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.fuser 219: echo `date '+%Y-%m-%d %T'` >> $err_log_path/"$dev"_$cyclenum.ps 220: /bin/cat $err_log_path/$dev.umount >> $err_log_path/"$dev"_$cyclenum.umount 2>&1 221: /bin/fuser -vum $mount_point >> $err_log_path/"$dev"_$cyclenum.fuser 2>&1 222: /bin/ps -ef >> $err_log_path/"$dev"_$cyclenum.ps 2>&1 223: echo "" >> $err_log_path/"$dev"_$cyclenum.umount 224: echo "" >> $err_log_path/"$dev"_$cyclenum.fuser 225: echo "" >> $err_log_path/"$dev"_$cyclenum.ps 226: 227: retry_count=`expr $retry_count - 1` 228: /bin/sleep $sleep_time 229: else 230: /bin/rm -f $err_log_path/$dev.umount 231: result_flag=0 232: break 233: fi 234: done 235: 236: if [ $result_flag != 0 ] 237: then 238: exit 10 239: fi 240: fi 241: echo "mount" > $post_file 242: 243: # fi 244: 245: # When device was not mounted 246: # 247: else 248: echo "none" > $post_file 249: fi 250: 251: exit 0