ページの先頭行へ戻る
ETERNUS SF AdvancedCopy Manager 15.2 運用ガイド
ETERNUS

A.3.1 リストア実行時の前処理

リストア実行時の前処理スクリプトは、以下のとおりです。

リストア時の前処理スクリプト

  1: // AdvancedCopy Manager for Windows
  2: // All Rights Reserved, Copyright FUJITSU LIMITED, 2002-2005
  3: //
  4: // OpcRestorePre.js: Pre-Processing Script for swstrestore
  5: //
  6: // [Parameters]
  7: // 1st argument: device name of transaction volume
  8: //
  9: // [Return Values]
 10: // 0: The script ended normally.
 11: // 2: The number of the arguments is incorrect.
 12: // 3: not used, but must not be used because older versions use these values.
 13: // 4: An error other than the above occurred.
 14: 
 15: try {
 16:     // create global objects
 17:     var WshShell = WScript.CreateObject("WScript.Shell");              // create Shell object
 18:     var WshEnv = WshShell.Environment("PROCESS");                      // create Environment object
 19:     var fsObj    = WScript.CreateObject("Scripting.FileSystemObject"); // create FileSystemObject object
 20: 
 21:     // create SwstRestorePreProc object
 22:     var proc = new SwstRestorePreProc();
 23: 
 24:     // there is nothing to do if the pre/post-processing is not customized
 25:     proc.doNothingForDriveLetter();
 26: 
 27:     SwstQuit(0);
 28: } catch (e) {
 29:     SwstQuit(4);
 30: }
 31: 
 32: function SwstRestorePreProc()
 33: {
 34:     // member variables
 35:     this.tvName       = WScript.Arguments.length!=1?SwstQuit(1):WScript.Arguments.Item(0); // device name of transaction volume
 36:     this.postFileName = getDataPathName() + "\\" + getPutFileName(this.tvName) + ".pre";   // name of postprocessing file
 37: 
 38:     // member functions
 39:     this.doNothingForDriveLetter = doNothingForDriveLetter; // self-explanatory
 40:     this.writePostFile           = writePostFile;           // self-explanatory
 41: }
 42: 
 43: function doNothingForDriveLetter()
 44: {
 45:     this.writePostFile("none");
 46: }
 47: 
 48: function writePostFile(type)
 49: {
 50:     var overwrite = true; // means to overwrite a file if it exists.
 51:     var postFileStream = fsObj.CreateTextFile(this.postFileName, overwrite);
 52:     postFileStream.Write(type);
 53:     postFileStream.Close();
 54: }
 55: 
 56: function SwstQuit(exitStatus)
 57: {
 58:     switch(exitStatus) {
 59:     case 0:
 60:         WScript.Quit(0);
 61:     case 1:
 62:         WScript.Echo("[Restore Preprocessing] The number of the arguments is incorrect.");
 63:         WScript.Quit(2);
 64:     default:
 65:         WScript.Echo("[Restore Preprocessing] The script exited abnormally.");
 66:         WScript.Quit(4);
 67:     }
 68: }
 69: 
 70: function getDataPathName()
 71: {
 72:     return WshShell.RegRead(getSetupInfoKey() + "\\etcPathName") + "\\etc\\backup\\data\\DEFAULT";
 73: }
 74: 
 75: function getBinPathName()
 76: {
 77:     return WshShell.RegRead(getSetupInfoKey() + "\\PathName") + "\\bin";
 78: }
 79: 
 80: function getSetupInfoKey()
 81: {
 82:     var nodeName = WshEnv.Item("SWSTGNODE");
 83:     if( nodeName != "" ){
 84:         return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion\\" + nodeName;
 85:     }
 86:     return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion";
 87: }
 88: 
 89: function getPutFileName(deviceName){
 90:     var fileName;
 91:     if( isSafeDISKName(deviceName) ){
 92:         var re = /(\S+)\/(\S+):(\S+)/;
 93:         fileName = deviceName.replace(re, "$1_$2_$3");
 94:     }else{
 95:         fileName = deviceName;
 96:     }
 97:     return(fileName);
 98: }
 99: 
100: function getGXDXPX(deviceName){
101:     var gXdXpX;
102:     if( isSafeDISKName(deviceName) ){
103:         var re = /(\S+)\/(\S+):(\S+)/;
104:         gXdXpX = deviceName.replace(re, "$3");
105:     }else{
106:         gXdXpX = deviceName;
107:     }
108:     return(gXdXpX);
109: }
110: 
111: function isSafeDISKName(deviceName){
112:     var key = ":g";
113:     var s = deviceName.indexOf(key);
114:     if ( s < 0 ) {
115:         return (false);
116:     } else {
117:         return (true);
118:     }
119: }