ETERNUS SF AdvancedCopy Manager Operator's Guide 13.0 -Microsoft(R) Windows(R) 2000- -Microsoft(R) Windows Server(TM) 2003-
Contents Index PreviousNext

Appendix B Sample Scripts

This appendix describes sample scripts for AdvancedCopy Manager.

A sample script allows you to back up data on a transaction volume by using AdvancedCopy Manager.

This section explains how the sample shell script is created for the backup management function. By using it as a reference when creating similar script for the replication management function, you can copy Oracle databases.

B.1 Overview 

Use AdvancedCopy Manager to back up a transaction volume.

AdvancedCopy Manager provides a sample scripts for backup. The manager of backup operation should correct the sample script according to the work and apply it to the actual backup operation.

This document and the sample script back up both the two drives on which all the physical data files in the table space in an instance to be backed up.

However, you can back up only a drive with a table space to be backed up by correcting the script.

Backup on AdvancedCopy Manager is performed in units of drives. If a drive with a data file in the table space to be backed up has data files in other table space, make an Oracle backup declaration for them also. To back up the SYSTEM table space shown in Figure B.1, for example, make Oracle backup declarations in all the five table spaces including other areas in the same volume.

A data file in the table space backed up without an Oracle backup declaration cannot be used for recovery because, even during backup, updating of the data file occurs to generate inconsistencies.

[Figure B.1 Relationship between an Oracle instance and data files in drive table spaces (in the case of this sample script)]

Sample scripts provided for AdvancedCopy Manager are created assuming that the following versions of Oracle are used. If you use any other version, correct the sample scripts as required.

B.2 Backup and Restoration of a Transaction volume 

This chapter describes performing backup and restoration of an Oracle database using AdvancedCopy Manager.

B.2.1 Backup procedure

The following shows an overview of the backup procedure.

  1. Checking the work operation status

    Check whether work is in operation or not.

  2. Stopping work

    If work is found to be in operation in Step 1, declare the start of online backup for the database and stop updating data files to make the disk partition that stores work data ready for online backup.

  3. Backing up (copying) a disk partition

    Using the backup function of AdvancedCopy Manager, back up (copy) a disk partition that stores work data.

  4. Restarting work

    If work is found to be in operation in Step 1, declare the end of online backup for the database and restart updating data files.

AdvancedCopy Manager provides a sample script that automatically performs Steps 2 through 5. For more information, see "Backup".

[Figure B.2 Backup]

B.2.2 Restoration procedure 

The following shows an overview of performing restoration from a backup disk.

  1. Checking the work stop status

    Check that work is stopped. If work is in operation, completely stop the work.

  2. Performing restoration from a backup disk

    Using the restoration function of AdvancedCopy Manager, restore data from a backup disk to a transaction volume.

[Figure B.3 Performing restoration from a backup disk]

B.3 Sample Scripts 

This chapter describes samples scripts provided for AdvancedCopy Manager.

B.3.1 Overview of sample scripts 

Samples scripts provided for AdvancedCopy Manager are stored under the "program-directory\etc\backup\sample" directory. Figure B.5 shows the correlation chart of sample scripts.

[Figure B.5 Correlation chart of sample scripts]

You are recommended to copy these sample scripts to an arbitrary folder before using them.

B.3.1.1 Collecting DB information

swst_or_iv.sql outputs the information of an Oracle database. This script outputs:

Use the above database information as reference for creating a script that performs backup.

  1. Start method

    sqlplus user-name/password@connection-string-for-DB-to-be-backed-up @swst_or_iv


  2. Usage example

    C:\>sqlplus system/manager@orcl @swst_or_iv <RETURN>

  3. Result example

    SQL*Plus: Release 8.1.6.0.0 - Production on Tue, May 22 21:33:21 2001
    (c) Copyright 1999 Oracle Corporation.  All rights reserved.
    Oracle8i Release 8.1.6.0.0 - Production
    JServer Release 8.1.6.0.0 - Production
    Connected to:
      TABLESPACE-NAME                       DEVICE-NAME
    -------------------- --------------------------------------------------
    INDX                 D:\ORACLE\ORADATA\CONTENTS\INDX01.DBF
    RBS                  D:\ORACLE\ORADATA\CONTENTS\RBS01.DBF
    SYSTEM               D:\ORACLE\ORADATA\CONTENTS\SYSTEM01.DBF
    TEMP                 D:\ORACLE\ORADATA\CONTENTS\TEMP01.DBF
    TOOLS                D:\ORACLE\ORADATA\CONTENTS\TOOLS01.DBF
    USERS                E:\ORACLE\ORADATA\CONTENTS\USERS01.DBF
    SQL> show parameters log_archive_dest
    NAME                                 TYPE
    ------------------------------------ --------------
    VALUE
    ------------------------------
    log_archive_dest                     string
    D:\Oracle\oradata\contents\arc
    hive
    log_archive_dest_1                   string
    log_archive_dest_2                   string
    log_archive_dest_3                   string
    log_archive_dest_4                   string
    log_archive_dest_5                   string
    log_archive_dest_state_1             string
    enable
    log_archive_dest_state_2             string
    enable
    log_archive_dest_state_3             string
    enable
    log_archive_dest_state_4             string
    enable
    log_archive_dest_state_5             string
    enable
    SQL>EXIT
    Oracle8i Release 8.1.6.0.0 - Production
    JServer Release 8.1.6.0.0 - Disconnect Production

The SQL*Plus tool comes in the following types, each of which corresponds to a version of Oracle.

Oracle version

Command-line-based version

Window-based version

Oracle7 Release7.3.x

PLUS33.EXE

PLUS33W.EXE

Oracle8 Release8.0.x

PLUS80.EXE

PLUS80W.EXE

Oracle8i Release8.1.x

SQLPLUS.EXE

SQLPLUSW.EXE

B.3.1.2 Backup

swst_or_bk_as.js backs up work data stored in an Oracle database on a file system, using AdvacncedCopy Manager.

Work data will be copied to a backup volume of AdvancedCopy Manager.

This script corresponds to Steps 2 through 5 described in "Backup procedure".

  1. Start method

    CSCRIPT.EXE swst_or_bk_as.js
  2. Usage example

    C:\>CSRIPT.EXE swst_or_bk_as.js
  3. Result example

    No result in particular will be output if the processing ends normally.

  4. Processing overview

    Main processing
    try {
        // create global objects
        var oracle_sid = "CONTENTS";                    // [[[ **1** TARGET INSTANCE NAME ]]]
        var ScriptPathName = "C:\\SCRIPT";              // [[[ **2** SCRIPT PATH ]]]
        var BinPathName = "C:\\WIN32APP\\AdvancedCopyManager\\bin"     // [[[ **3** SCRIPT PATH ]]]
        var OraclePathName = "D:\\Oracle\\Ora81\\bin";  // [[[ **4** ORACLE PATH ]]]
        var OracleServerManager9i = "sqlplus /nolog";   // [[[ ORACLE SERVER MANAGER  Oracle9i ]]]
        var OracleServerManager8i = "svrmgrl";          // [[[ ORACLE SERVER MANAGER Oracle8i ]]]
        var OracleServerManager8 = "svrmgr30";          // [[[ ORACLE SERVER MANAGER Oracle8.x ]]]
        var OracleServerManager7 = "svrmgr23";          // [[[ ORACLE SERVER MANAGER Oracle7.x ]]]
        var OracleSM = OraclePathName + "\\" + OracleServerManager8i;       // [[[ **5** PLEASE SELECT ]]]             ----- One is chosen and described from above four.
        var FirstBusinessVolumeName = "g3d0p2";                        // [[[ **6** 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);             // [[[ ***7*** FileName ]]]
        if (CheckErrorLog != 0) {
            ExecSql(swst_first_ed.sql", false);         // [[[ ***8*** FileName ]]]
            swstQuit (1);
        }
        var returnCode = WshShell.Run(BinPathName + "\\swstbackup g3d0p2 -Xdevmap " + 
                    ScriptPathName + "\\swst_devmap.txt", 0, true);     // [[[ ***9*** DeviceName FileName ]]]
        ExecSql("swst_first_ed.sql", false);                            // [[[ ***10*** 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);                           // [[[ ***11*** FileName ]]]
        if (CheckErrorLog != 0) {
            ExecSql("swst_second_ed.sql, false");                       // [[[ ***12*** FileName ]]]
            swstQuit (1);
        }
              var returnCode = WshShell.Run(BinPathName + "\\swstbackup g3d0p3 -Xdevmap " + 
                    ScriptPathName + "\\swst_devmap.txt", 0, true);     // [[[ ***13*** DeviceName FileName ]]]
        ExecSql("swst_second_ed.sql", false);                           // [[[ ***14*** FileName ]]]
        if (CheckErrorLog != 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

B.3.2 Applying a sample script 

B.3.2.1 Updating a sample script

Update a sample script so that it is appropriate for the actual operation.

This sample script assumes that physical file of an instance is stored over two drives. If the information of an instance referenced as described in "Collecting DB information" has only one drive, delete the two parts enclosed between the following lines. If more than two drives are used, copy the parts for the third and later drives and correct each of them.
//[[[ Second Drive  - START - ]]] 
          XXXXXXX
          XXXXXXX
//[[[ Second Drive  - END - ]]]
Change the svrmgrl command to the sqlplus command (nolog/option specification) for Oracle9i.

This script operates only on a storage server of AdvancedCopy Manager.

B.3.2.2 Creating a volume locking specification file 

In the sample script (swst_or_bk_as.js) updated as described in "Updating a sample script", the AdvancedCopy Manager backup command (swstbackup) is excuted. The AdvancedCopy Manager backup command normally locks a volume to be backed up so that no file is updated while being backed up.

As explained above, only flushing of the file system buffer without locking of the backup target volume is necessary for execution of the AdvancedCopy Manager backup command with the backup target volume of the Oracle database specified as in "Updating sample scripts." Therefore, change preprocessing and postprocessing operations in the transaction volume locking specification file for backups. An example of settings is shown below. If a machine in the SP-series is not used, then the preprocessing and postprocessing operations can be changed by specifying the Xflush option in the swstbackup command.

B.3.3 Restoration methods 

Use the restoration function of AdvancedCopy Manager to perform restoration.

To restore only part of the files on a transaction volume, use the restoration command (swstrestore) of AdvancedCopy Manager with the -r operand specified to restore backup data to a work drive. Use the copy command of the OS to copy only destroyed files from the work drive.

B.3.4 Notes on using sample scripts 

B.3.4.1 Location of Oracle resources 

Store data files and other files of Oracle on different disks or in different partitions.

B.3.4.2 Backup operation of Oracle resources 

There are the following notes.

  1. Initialization parameter file

    Whenever a change is made, back up this file using the copy command, etc. of the OS.

  2. Control files

  3. Data files

  4. REDO files

For online backup operations, the target Oracle database must use an archive log.

B.3.4.3 Recovery of Oracle databases 

To recover an Oracle database to the latest status, first restore the Oracle database and replace the files in which the error occurred with restored files, using the recovery function of Oracle.

Example: recover tablespace

For information on the recovery function of Oracle databases, see "Oracle8i Backup and Recovery Guide" (if the database is Oracle8i).


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2002-2006