リストア実行時の後処理スクリプトは、以下のとおりです。
クラスタ運用でない場合
<環境設定ディレクトリ>\etc\backup\scripts\OpcRestorePost.jsクラスタ運用の場合
<共有ディスク>:\etc\opt\swstorage\etc\backup\scripts\OpcRestorePost.jsリストア時の後処理スクリプト
1: // AdvancedCopy Manager for Windows
2: // All Rights Reserved, Copyright FUJITSU LIMITED, 2002-2006
3: //
4: // OpcRestorePost.js: Post-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,5): 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 SwstRestorePostProc object
22: var proc = new SwstRestorePostProc();
23:
24: // do nothing if postprocessing file exists
25: if (fsObj.FileExists(proc.postFileName) == false) {
26: proc.doNothing();
27: }
28: // get postprocessing type
29: else {
30: var postProcType = proc.getPostProcType();
31: switch(postProcType) {
32: case "none":
33: proc.doNothing();
34: break;
35: }
36: }
37:
38: // clear temporary file
39: proc.deletePostFile();
40: SwstQuit(0);
41: } catch (e) {
42: SwstQuit(6);
43: }
44:
45: function SwstRestorePostProc()
46: {
47: // member variables
48: this.tvName = WScript.Arguments.length!=1?SwstQuit(1):WScript.Arguments.Item(0); // device name of transaction volume
49: this.postFileName = getDataPathName() + "\\" + getPutFileName(this.tvName) + ".pre"; // name of postprocessing file
50:
51: // member functions
52: this.getPostProcType = getPostProcType; // self-explanatory
53: this.doNothing = doNothing; // self-explanatory
54: this.deletePostFile = deletePostFile; // self-explanatory
55: }
56:
57: function getPostProcType()
58: {
59: var iomode = 1; // means read-only mode
60: var create = false; // means not to create a file
61: var postFileStream = fsObj.OpenTextFile(this.postFileName, iomode, create);
62: var postProc = postFileStream.ReadAll();
63: postFileStream.Close();
64: return postProc;
65: }
66:
67: function doNothing()
68: {
69: // do nothing
70: }
71:
72: function deletePostFile()
73: {
74: if (fsObj.FileExists(this.postFileName) == true) {
75: fsObj.DeleteFile(this.postFileName);
76: }
77: }
78:
79: function SwstQuit(exitStatus)
80: {
81: switch(exitStatus) {
82: case 0:
83: WScript.Quit(0);
84: case 1:
85: WScript.Echo("[Restore Postprocessing] The number of the arguments is incorrect.");
86: WScript.Quit(2);
87: default:
88: WScript.Echo("[Restore Postprocessing] The script exited abnormally.");
89: WScript.Quit(4);
90: }
91: }
92:
93: function getDataPathName()
94: {
95: return WshShell.RegRead(getSetupInfoKey() + "\\etcPathName") + "\\etc\\backup\\data\\DEFAULT";
96: }
97:
98: function getBinPathName()
99: {
100: return WshShell.RegRead(getSetupInfoKey() + "\\PathName") + "\\bin";
101: }
102:
103: function getSetupInfoKey()
104: {
105: var nodeName = WshEnv.Item("SWSTGNODE");
106: if( nodeName != "" ){
107: return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion\\" + nodeName;
108: }
109: return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion";
110: }
111:
112: function getPutFileName(deviceName){
113: var fileName;
114: if( isSafeDISKName(deviceName) ){
115: var re = /(\S+)\/(\S+):(\S+)/;
116: fileName = deviceName.replace(re, "$1_$2_$3");
117: }else{
118: fileName = deviceName;
119: }
120: return(fileName);
121: }
122:
123: function getGXDXPX(deviceName){
124: var gXdXpX;
125: if( isSafeDISKName(deviceName) ){
126: var re = /(\S+)\/(\S+):(\S+)/;
127: gXdXpX = deviceName.replace(re, "$3");
128: }else{
129: gXdXpX = deviceName;
130: }
131: return(gXdXpX);
132: }
133:
134: function isSafeDISKName(deviceName){
135: var key = ":g";
136: var s = deviceName.indexOf(key);
137: if ( s < 0 ) {
138: return (false);
139: } else {
140: return (true);
141: }
142: } |
ポイント
業務ボリュームのロック/ロック解除はスクリプトではなく、コマンド内で実施されています。したがって、リストア前処理スクリプトおよびリストア後処理スクリプトは、業務ボリュームのロック/ロック解除の処理の直前と直後で、それぞれ実行されます。
図A.7 リストア

注意
リストア前処理では、ほかのアプリケーションとの一時的なアクセス競合を回避するため、ロックに失敗した場合にロック処理をリトライします。既定のリトライ回数を超えた場合、コマンドは異常終了します。この場合、リストア先ボリュームを使用しているプロセスが存在しているため、アプリケーションやサービスを停止するなどの対処を実施し、ほかのプロセスがボリュームを使用していない状態にしてください。リトライ回数は、「A.3.3 リストア先ボリュームロック動作指定ファイル」で変更できます。
なお、リストア処理実行時にほかのプロセスが処理対象ボリュームを使用しないための対策が適切に行われている場合、通常、これらのファイルは作成不要です。