The sample scripts that are provided for AdvancedCopy Manager are stored as follows. For the backup management function, the sample script is stored under the "C:\Win32app\AdvancedCopyManager\etc\backup\sample" directory. For the replication management function, the sample script is stored under the "C:\Win32app\AdvancedCopyManager\etc\repl\sample" directory. The figure below shows the correlation chart of sample scripts.
Figure B.4 Correlation Chart of Sample Scripts
Note
It is recommended that these sample scripts are copied to different folder before using them.
The sample script for the backup management function (swst_or_iv.sql) or for the replication management function (swsrp_or_iv.sql) outputs the Oracle database information. This script outputs:
A list of table space names and storage destinations
Information from the log file of an Oracle database
Use the above database information as a reference for creating a script that performs backup.
Sample Script for the Backup Management Function
Start Method
sqlplus user-name/password@connection-string-for-DB-to-be-backed-up @swst_or_iv
Usage Example
C:\>sqlplus system/manager@orcl @swst_or_iv
Result Example
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jul 4 14:06:48 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Last Successful login time: Wed Jul 04 2018 14:01:00 +09:00 Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production TABLESPACE-NAME DEVICE-NAME -------------------- -------------------------------------------------- SYSAUX D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF SYSTEM D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF UNDOTBS1 D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF USERS D:\ORACLE\ORADATA\ORCL\USERS01.DBF NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ log_archive_dest string log_archive_dest_1 string log_archive_dest_10 string log_archive_dest_11 string log_archive_dest_12 string log_archive_dest_13 string log_archive_dest_14 string log_archive_dest_15 string log_archive_dest_16 string log_archive_dest_17 string log_archive_dest_18 string log_archive_dest_19 string log_archive_dest_2 string log_archive_dest_20 string log_archive_dest_21 string log_archive_dest_22 string log_archive_dest_23 string log_archive_dest_24 string log_archive_dest_25 string log_archive_dest_26 string log_archive_dest_27 string log_archive_dest_28 string log_archive_dest_29 string log_archive_dest_3 string log_archive_dest_30 string log_archive_dest_31 string log_archive_dest_4 string log_archive_dest_5 string log_archive_dest_6 string log_archive_dest_7 string log_archive_dest_8 string log_archive_dest_9 string log_archive_dest_state_1 string enable log_archive_dest_state_10 string enable log_archive_dest_state_11 string enable log_archive_dest_state_12 string enable log_archive_dest_state_13 string enable log_archive_dest_state_14 string enable log_archive_dest_state_15 string enable log_archive_dest_state_16 string enable log_archive_dest_state_17 string enable log_archive_dest_state_18 string enable log_archive_dest_state_19 string enable log_archive_dest_state_2 string enable log_archive_dest_state_20 string enable log_archive_dest_state_21 string enable log_archive_dest_state_22 string enable log_archive_dest_state_23 string enable log_archive_dest_state_24 string enable log_archive_dest_state_25 string enable log_archive_dest_state_26 string enable log_archive_dest_state_27 string enable log_archive_dest_state_28 string enable log_archive_dest_state_29 string enable log_archive_dest_state_3 string enable log_archive_dest_state_30 string enable log_archive_dest_state_31 string enable log_archive_dest_state_4 string enable log_archive_dest_state_5 string enable log_archive_dest_state_6 string enable log_archive_dest_state_7 string enable log_archive_dest_state_8 string enable log_archive_dest_state_9 string enable Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Sample Script for the Replication Management Function
Start Method
sqlplus user-name/password@connection-string-for-DB-to-be-backed-up @swsrp_or_iv
Usage Example
C:\>sqlplus system/manager@orcl @swsrp_or_iv
Result Example
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jul 4 14:09:35 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Last Successful login time: Wed Jul 04 2018 14:09:24 +09:00 Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production TABLESPACE-NAME DEVICE-NAME -------------------- -------------------------------------------------- SYSAUX D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF SYSTEM D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF UNDOTBS1 D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF USERS D:\ORACLE\ORADATA\ORCL\USERS01.DBF NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ log_archive_dest string log_archive_dest_1 string log_archive_dest_10 string log_archive_dest_11 string log_archive_dest_12 string log_archive_dest_13 string log_archive_dest_14 string log_archive_dest_15 string log_archive_dest_16 string log_archive_dest_17 string log_archive_dest_18 string log_archive_dest_19 string log_archive_dest_2 string log_archive_dest_20 string log_archive_dest_21 string log_archive_dest_22 string log_archive_dest_23 string log_archive_dest_24 string log_archive_dest_25 string log_archive_dest_26 string log_archive_dest_27 string log_archive_dest_28 string log_archive_dest_29 string log_archive_dest_3 string log_archive_dest_30 string log_archive_dest_31 string log_archive_dest_4 string log_archive_dest_5 string log_archive_dest_6 string log_archive_dest_7 string log_archive_dest_8 string log_archive_dest_9 string log_archive_dest_state_1 string enable log_archive_dest_state_10 string enable log_archive_dest_state_11 string enable log_archive_dest_state_12 string enable log_archive_dest_state_13 string enable log_archive_dest_state_14 string enable log_archive_dest_state_15 string enable log_archive_dest_state_16 string enable log_archive_dest_state_17 string enable log_archive_dest_state_18 string enable log_archive_dest_state_19 string enable log_archive_dest_state_2 string enable log_archive_dest_state_20 string enable log_archive_dest_state_21 string enable log_archive_dest_state_22 string enable log_archive_dest_state_23 string enable log_archive_dest_state_24 string enable log_archive_dest_state_25 string enable log_archive_dest_state_26 string enable log_archive_dest_state_27 string enable log_archive_dest_state_28 string enable log_archive_dest_state_29 string enable log_archive_dest_state_3 string enable log_archive_dest_state_30 string enable log_archive_dest_state_31 string enable log_archive_dest_state_4 string enable log_archive_dest_state_5 string enable log_archive_dest_state_6 string enable log_archive_dest_state_7 string enable log_archive_dest_state_8 string enable log_archive_dest_state_9 string enable Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
The sample script for the backup management function (swst_or_bk_as.js) or for the replication management function (swsrp_or_bk_as.js) backs up processing data stored in an Oracle database on a file system, using AdvancedCopy Manager.
Processing data is copied to a backup volume of AdvancedCopy Manager.
This script corresponds to steps 2 through 5 described in "B.1.1 Backup Procedure".
Sample Script for the Backup Management Function
Start Method
CSCRIPT.EXE swst_or_bk_as.js
Usage Example
C:\>CSRIPT.EXE swst_or_bk_as.js
Result Example
No result is output if the processing ends normally.
Processing Overview
Main processing try { // create global objects var oracle_sid = "ORCL"; // [[[ **1** TARGET INSTANCE NAME ]]] var ScriptPathName = "C:\\SCRIPT"; // [[[ **2** SCRIPT PATH ]]] var BinPathName = "C:\\WIN32APP\\AdvancedCopyManager\\bin" // [[[ **3** SCRIPT PATH ]]] var OraclePathName = "D:\\app\\administrator\\product\\12.2.0\\dbhome_1\\bin"; // [[[ **4** ORACLE PATH ]]] var OracleSM = OraclePathName + "\\" + "sqlplus /nolog"; var FirstBusinessVolumeName = "g3d0p2"; // [[[ **5** First Business Volume Name ]]] var WorkBatchfile = ScriptPathName + "\\work" + FirstBusinessVolumeName + ".bat"; // [[[ Work Batchfile ]]] var ErrorLogfile = ScriptPathName + "\\error" + FirstBusinessVolumeName + ".log"; // [[[ Error Logfile ]]] // create Shell object var WshShell = WScript.CreateObject("WScript.Shell"); ***** The backup file processing start of a one-eyed drive ****** //[[[ First Drive - START - ]]] ExecSql("swst_first_st.sql", true); // [[[ ***6*** FileName ]]] if (CheckErrorLog() != 0) { ExecSql("swst_first_ed.sql", false); // [[[ ***7*** FileName ]]] SwstQuit (1); } var returnCode = WshShell.Run(BinPathName + "\\swstbackup g3d0p2 -Xdevmap " + ScriptPathName + "\\swst_xdevmap.txt", 0, true); // [[[ ***8*** DeviceName FileName ]]] ExecSql("swst_first_ed.sql", false); // [[[ ***9*** FileName ]]] if (returnCode != 0) { SwstQuit (2); } else if (CheckErrorLog() != 0) { SwstQuit (1); } //[[[ First Drive - END - ]]] ***** The backup file processing end of a one-eyed drive ****** ***** The backup file processing start of the second drive ****** //[[[ Second Drive - START - ]]] ExecSql("swst_second_st.sql", false); // [[[ ***10*** FileName ]]] if (CheckErrorLog() != 0) { ExecSql("swst_second_ed.sql", false); // [[[ ***11*** FileName ]]] SwstQuit (1); } var returnCode = WshShell.Run(BinPathName + "\\swstbackup g3d0p3 -Xdevmap " + ScriptPathName + "\\swst_xdevmap.txt", 0, true); // [[[ ***12*** DeviceName FileName ]]] ExecSql("swst_second_ed.sql", false); // [[[ ***13*** FileName ]]] if (returnCode != 0) { SwstQuit (2); } else if (CheckErrorLog() != 0) { SwstQuit (1); } //[[[ Second Drive - END - ]]] ***** The backup file processing end of the second drive ****** An error log is deleted at the time of a normal end, and it is completed. var fs = WScript.CreateObject("Scripting.FileSystemObject"); var fs_d = fs.GetFile(ErrorLogfile); fs_d.Delete(true); SwstQuit(0); //Normal END } catch (e) { In an error, it ends, without deleting an error log file. SwstQuit(3); //Abnomal END } function ExecSql(fileName, flg) The SQL script file name to perform is received and it performs by the server manager. The 2nd argument is the overwrite propriety flag of a log. function CheckErrorLog() It checks whether the inside of the log file acquired by the redirection after server manager execution is searched, and there is any error of an oracle. function SwstQuit(exitStatus) Error processing
Sample Script for the Replication Management Function
Start Method
CSCRIPT.EXE swsrp_or_bk_as.js
Usage Example
C:\>CSRIPT.EXE swsrp_or_bk_as.js
Result Example
No result is output if the processing ends normally.
Processing Overview
Main processing try { // create global objects var oracle_sid = "ORCL"; // [[[ **1** TARGET INSTANCE NAME ]]] var ScriptPathName = "C:\\SCRIPT"; // [[[ **2** SCRIPT PATH ]]] var BinPathName = "C:\\WIN32APP\\AdvancedCopyManager\\bin" // [[[ **3** SCRIPT PATH ]]] var OraclePathName = "D:\\app\\administrator\\product\\12.2.0\\dbhome_1\\bin"; // [[[ **4** ORACLE PATH ]]] var OracleSM = OraclePathName + "\\" + "sqlplus /nolog"; var FirstBusinessVolumeName = "g3d0p2"; // [[[ **5** First Business Volume Name ]]] var WorkBatchfile = ScriptPathName + "\\work" + FirstBusinessVolumeName + ".bat"; // [[[ Work Batchfile ]]] var ErrorLogfile = ScriptPathName + "\\error" + FirstBusinessVolumeName + ".log"; // [[[ Error Logfile ]]] // create Shell object var WshShell = WScript.CreateObject("WScript.Shell"); ***** The backup file processing start of a one-eyed drive ****** //[[[ First Drive - START - ]]] ExecSql("swsrp_first_st.sql", true); // [[[ ***6*** FileName ]]] if (CheckErrorLog() != 0) { ExecSql("swsrp_first_ed.sql", false); // [[[ ***7*** FileName ]]] SwsrpQuit(1); } var returnCode = WshShell.Run(BinPathName + "\\swsrpmake g3d0p2 g3d1p2@TARG-SV", 0, true); // [[[ ***8*** fromVolumeName toVolumeName@targetServerName ]]] ExecSql("swsrp_first_ed.sql", false); // [[[ ***9*** FileName ]]] if (returnCode != 0) { SwsrpQuit(2); } else if (CheckErrorLog() != 0) { SwsrpQuit(1); } //[[[ First Drive - END - ]]] ***** The backup file processing end of a one-eyed drive ****** ***** The backup file processing start of the second drive ****** //[[[ Second Drive - START - ]]] ExecSql("swsrp_second_st.sql", false); // [[[ ***10*** FileName ]]] if (CheckErrorLog() != 0) { ExecSql("swsrp_second_ed.sql", false); // [[[ ***11*** FileName ]]] SwsrpQuit(1); } var returnCode = WshShell.Run(BinPathName + "\\swsrpmake g3d0p3 g3d1p3@TARG-SV", 0, true); // [[[ ***12*** fromVolumeName toVolumeName@targetServerName ]]] ExecSql("swsrp_second_ed.sql", false); // [[[ ***13*** FileName ]]] if (returnCode != 0) { SwsrpQuit(2); } else if (CheckErrorLog() != 0) { SwsrpQuit(1); } //[[[ Second Drive - END - ]]] ***** The backup file processing end of the second drive ****** An error log is deleted at the time of a normal end, and it is completed. var fs = WScript.CreateObject("Scripting.FileSystemObject"); var fs_d = fs.GetFile(ErrorLogfile); fs_d.Delete(true); SwsrpQuit(0); //Normal END } catch (e) { In an error, it ends, without deleting an error log file. SwsrpQuit(3); //Abnomal END } function ExecSql(fileName, flg) The SQL script file name to perform is received and it performs by the server manager. The 2nd argument is the overwrite propriety flag of a log. function CheckErrorLog() It checks whether the inside of the log file acquired by the redirection after server manager execution is searched, and there is any error of an oracle. function SwsrpQuit(exitStatus) Error processing