ETERNUS SF AdvancedCopy Manager Operator's Guide 13.0 -AIX-
Contents Index PreviousNext

Appendix C Sample Shell Script for Backup Operations

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 or DB2 databases.

C.1 Overview 

Use AdvancedCopy Manager to back up a transaction volume.

AdvancedCopy Manager provides some sample shell scripts for backup processing. The backup operation administrator must modify the sample shell scripts by adjusting them appropriately for the business at hand and then apply them to actual backup operations.

C.2 Backup and Restoration of a Transaction volume 

C.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. Business stoppage

    For business in progress in 1, make contents of each transaction volume consistent.

  3. Disk backup

    Create backup copies of transaction volumes by using the backup function of AdvancedCopy Manager.

  4. Business restart

    For business in progress in 1, restart the business at hand.

[Figure Backup method]

C.2.2 Restoration procedure 

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

  1. Checking the work stop status

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

  2. Restore

    Use the restoration function of AdvancedCopy Manager to perform restoration from the backup volume to the transaction volume.

  3. Business restart

[Figure Restore method]

C.3 Sample Shell Scripts for Oracle 

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.

C.3.1 Overview of sample shell scripts 

The sample shell scripts provided by AdvancedCopy Manager are summarized below. These sample shell scripts are stored in the /etc/opt/FJSVswsts/samp directory.

No.

Type

Script name

Associated transaction

Associated resource type

1

Collection of DB information

swst_or_iv

Oracle transaction

-

2

Backup

swst_or_rd_bk

Oracle transaction

Raw device

When a database exists on a file system, it cannot back up during starting of the business which uses the database.

C.3.1.1 Collecting DB information 

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

Output file names and their contents are as follows:

The above files are used as references for creating shell scripts used for backup processing.

  1. Start

    swst_or_iv

     

  2. Usage example

    # swst_or_iv 
    swst_or_iv completed.

     

  3. Result example

    spdata.lst
    TABLESPACE-NAME               DEVICE-NAME
    -------------------- --------------------------------------------------
    ORA10                /ora1/ora0.dbf
    ORA20                /ora2/ora0.dbf
    RBS                  /oracle/ora/oradata/rbs01.dbf
    SYSTEM               /oracle/ora/oradata/system01.dbf
    TEMP                 /oracle/ora/oradata/temp01.dbf
    TOOLS                /oracle/ora/oradata/tools01.dbf
    USERS                /oracle/ora/oradata/users01.dbf
    ACMTS1               /dev/rlvol36001
    spdata.bgn
    alter tablespace ORA10 begin backup;
    alter tablespace ORA20 begin backup;
    alter tablespace RBS begin backup;
    alter tablespace SYSTEM begin backup;
    alter tablespace TEMP begin backup;
    alter tablespace TOOLS begin backup;
    alter tablespace USERS begin backup;
    alter tablespace ACMTS1 begin backup;
    spdata.end
    alter tablespace ORA10 end backup;
    alter tablespace ORA20 end backup;
    alter tablespace RBS end backup;
    alter tablespace SYSTEM end backup;
    alter tablespace TEMP end backup;
    alter tablespace TOOLS end backup;
    alter tablespace USERS end backup;
    alter tablespace ACMTS1 end backup;
    spcont.lst
    NAME                  TYPE    VALUE
    ----------------------------------- ------- ------------------------------
    control_files         string  /oracle/ora/oradata/control
    splog.lst
    NAME                  TYPE    VALUE
    ----------------------------------- ------- ------------------------------
    log_archive_dest      string  /oracle/ora/oradata/archive
    spredolog.lst
    GROUP#       MEMBER
    ----------   --------------------------------------------------------------------------------
        3        /work/u01/app/oracle/oradata/acmtest1/redo03.log
        2        /work/u01/app/oracle/oradata/acmtest1/redo02.log
        1        /work/u01/app/oracle/oradata/acmtest1/redo01.log

     

  4. Processing outline

    #!/bin/sh
    reterr() --- An error message is output before an error is returned.
    sqldata()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    SELECT --- Acquire Oracle table space information.
    }
    sqllog()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    show --- Acquire Oracle log information.
    }
    sqlcont()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    show --- Acquire Oracle control information.
    }
    sqlredolog()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    show --- Acquire Oracle REDO log information.
    }
    # main()
    # 0) Environmental variable setting
    PATH=$PATH:/usr/bin:/usr/sbin:/opt/FJSVswsts/bin
    # 1) Acquisition of Oracle table space information
    sqldata() invocation --- Acquire Oracle table space information
    # 2) Acquisition of Oracle log information
    sqllog() invocation --- Acquire Oracle log information
    # 3) Acquisition of Oracle control information
    sqlcont() invocation --- Acquire Oracle control information
    # 4) Acquisition of Oracle REDO log information
    sqlredolog() invocation --- Acquire Oracle REDO log information
    exit 0

C.3.1.2 Backup 

swst_or_vg_bk run AdvancedCopy Manager to back up business data using an Oracle database on a raw device.

Business data is copied to work disks prepared by users.

These scripts applies to steps 2 to 4 in "Backup procedure."

  1. Start

    swst_or_vg_bk  {-a | -i} <volume group name>

     

  2. Explanation of operands

    -a:  Specify when business using an Oracle database is active.  The start of backup processing is declared to the Oracle server.
    -i:  Specify when business using an Oracle database is stopped or the file is a general file.  The start of backup processing is not declared to the Oracle server.
    volume group name:  Specify the name of the volume group targeted for backup.

     

  3. Example of using swst_or_vg_bk

    While business is active, back up /dev/vg01 in which an Oracle database is located.
    #  swst_or_vg_bk  -a  /dev/vg01
    swst_or_vg_bk  completed. (/dev/vg01 -> /dev/vg02 at 23:01 on 2005.10.01 )

     

  4. Processing outline of swst_or_vg_bk

    #!/bin/sh
    usage() --- Command syntax is output before an error is returned.
    reterr() --- An error message is output before an error is returned.
    get_chr_blk() --- Conversion from a character device to a block device
    get_blk_chr() --- Conversion from a block device to a character device
    sqlbegin()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    alter system switch logfile;
    alter system flush shared_pool;
    alter tablespace CCC begin backup; --- Notify Oracle of the start of backup.
    }
    sqlend()
    {
    sqlplus /nolog <<!
    connect / as sysdba
    alter tablespace CCC end backup; --- Notify Oracle of the stopping of backup.
    }
    getbd() --- Fetch the name of the backup (copy) destination device of AdvancedCopy Manager.
    getdate() --- Fetch the backup (copy) date of AdvancedCopy Manager.
    gettime() --- Fetch the backup (copy) time of AdvancedCopy Manager.
    # main()
    Parameter analysis and raw device check
    # 0) Environmental variable setting
    PATH=$PATH:/usr/bin:/usr/sbin:/opt/FJSVswsts/bin
    # 1) Notification issued to Oracle of the start of backup
    if [ "-a" operand specification ]
    then
    sqlbegin() invocation --- Notify Oracle of the start of backup.
    Error handling
    fi
    # 2) Disk backup (copy) by AdvancedCopy Manager command
    swstbackup $SRC --- Copy the disk.
    Error handling
    # 3) Notification issued to Oracle of the stopping of backup
    if [ "-a" operand specification ]
    then
    sqlend() invocation --- Notify Oracle of the stopping of backup.
    Error handling
    fi
    # 4) Acquisition of the backup (copy) destination of AdvancedCopy Manager
    DSTBLK="`getbd $SRC`" --- Fetch a backup volume.
    BKDATE="`getdate $SRC`"
    BKTIME="`gettime $SRC`"
    exit 0

C.3.2 Applying the sample shell scripts 

C.3.2.1 DB information collection 

+Sample shell script update

Update the procedures below of swst_or_iv to adjust them for actual operations. The following numbers correspond to those in the scripts.

0) Environmental variable setting

1) Acquisition of Oracle table space information

2) Acquisition of Oracle log information

3) Acquisition of Oracle control information

The above procedures 1) to 3) change Oracle account information.

These scripts can operate only on business servers of AdvancedCopy Manager.

C.3.2.2 Backup 

+AdvancedCopy Manager setup

Set up backup volumes so that the raw devide targeted for backup is backed up correctly in AdvancedCopy Manager.

The generations of the backup volumes to be managed are arbitrary.

+Sample shell script update

Update the procedures below of swst_or_vg_bk to adjust them for actual operations. The following numbers correspond to those in the scripts.

0) Environmental variable setting

1) Notification issued to Oracle of the start of backup

3) Notification issued to Oracle of the stopping of backup

The above procedures 1) and 3) refer to the spdata.lst file, spdata.bgn file, spdata.end file, splog.lst file, spredolog.lst file, and spcont.lst file created by swst_or_iv.

These scripts can operate only on business servers of AdvancedCopy Manager.

+Recording and managing the backup volume name and processing time

After executing a shell script, a backup volume name and the processing time are output in a message. When restoring it, these information is needed. Thus, the backup volume name and processing time output in a message after execution of a shell script must be recorded and managed.

C.3.3 Restore Method 

Use the restore function of AdvancedCopy Manager for restore processing.

C.3.4 Notes about using the sample shell scripts 

+Oracle resource location

Store Oracle data files and files other than data files on separate disks or in separate slices.

+Backup operation of Oracle resources

  1. Initialization parameter file

    1. Every time a change occurs, the cp command of the OS is executed for backup.

  2. Control files

    1. You are recommended to use mirroring due to Oracle.

    2. If a change is made in the DB environment, use the following command to create a trace file. If a control file is destroyed, execute the SQL statement in the trace file to recover the control file.

      alter database backup control file to trace;

  3. Data files

    1. The recommended location of data files is on a raw device.

    2. To store a data file on the file system, disable the automatic extended function of the data file (AUTOEXTEND OFF). Then, customization of the sample shell script is required to prevent unmounting during context processing.

    3. Create backup copies in AdvancedCopy Manager.

    4. The range of table spaces targeted for backup must be within the unit of synchronous backup processing (begin backup/end backup) in Oracle and the unit of backup in AdvancedCopy Manager. For example, if backup copies must be created in units of LUNs in AdvancedCopy Manager, place one table space in one LUN.

    5. Archive all of the latest logs by executing the following command after backing up all table spaces in the system:

      alter system archive log current;

  4. REDO files

    1. You are recommended to mirror online REDO log files and archive log files using Oracle or the OS.

    2. No online REDO log file needs to be backed up.

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

+Recovery of Oracle databases

After Oracle database has stopped, restore the database, and restart it. To recover the database to the latest state, use the recovery function of Oracle.

C.4 Sample Shell Scripts for DB2 

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

C.4.1 Overview of sample shell scripts 

The sample shell scripts provided by AdvancedCopy Manager are summarized below. These sample shell scripts are stored in the /etc/opt/FJSVswsts/samp directory.

No.

Type

Script name

Associated transaction

Associated resource type

1

Collection of DB information

swst_db2_iv

DB2 transaction

-

2

Backup

swst_db2_vg_bk

DB2 transaction

Raw device

When a database exists on a file system, it cannot back up during starting of the business which uses the database.

C.4.1.1 Collecting DB information 

swst_db2_iv outputs the information of an DB2 database. This script outputs:

Output file names and their contents are as follows:

The above files are used as references for creating shell scripts used for backup processing.

  1. Start

    swst_db2_iv

     

  2. Usage example

    # swst_db2_iv 
    swst_db2_iv completed.

     

  3. Result example

    spdata.lst
    TABLESPACE-NAME      DEVICE-NAME
    -------------------- --------------------------------------------------
    SYSCATSPACE          /work/ACM_DB2/db2inst1/database/db2inst1/NODE0000/SQL00001/SQLT0000.0
    TEMPSPACE1           /work/ACM_DB2/db2inst1/database/db2inst1/NODE0000/SQL00001/SQLT0001.0
    USERSPACE1           /work/ACM_DB2/db2inst1/database/db2inst1/NODE0000/SQL00001/SQLT0002.0
    ACMTS34              /dev/rlvol34001
    SYSTOOLSPACE         /work/ACM_DB2/db2inst1/database/db2inst1/NODE0000/SQL00001/SYSTOOLSPACE

     

  4. Processing outline

    #!/bin/sh
    reterr() --- An error message is output before an error is returned.
    sqldata()
    {
    db2 list tablespaces ----------------------------------- Acquisition of table space name and table space ID
    db2 list tablespace containers for <table space ID> --- Acquisition of device name
    }
    # main()
    # 0) Environmental variable setting
    PATH=$PATH:/usr/bin:/usr/sbin
    # 1) Acquisition of DB2 table space information
            db2 connect to acmtest1 --- Connect the DB2
            sqldata
            db2 terminate ------------- Terminate the DB2
    exit 0

C.4.1.2 Backup 

swst_db2_vg_bk run AdvancedCopy Manager to back up business data using an DB2 database on a raw device.

Business data is copied to work disks prepared by users.

These scripts applies to steps 2 to 4 in "Backup procedure."

  1. Start

    swst_db2_vg_bk  {-a | -i} <volume group name>

     

  2. Explanation of operands

    -a:  Specify when business using an DB2 database is active.  The start of backup processing is declared to the Oracle server.
    -i:  Specify when business using an DB2 database is stopped or the file is a general file.  The start of backup processing is not declared to the Oracle server.
    volume group name:  Specify the name of the volume group targeted for backup.

     

  3. Example of using swst_db2_vg_bk

    While business is active, back up /dev/vg01 in which an DB2 database is located.
    #  swst_db2_vg_bk  -a  /dev/vg01
    swst_db2_vg_bk  completed. (/dev/vg01 -> /dev/vg02 at 23:01 on 2005.10.01 )

     

  4. Processing outline of swst_db2_vg_bk

    #!/bin/sh
    usage() --- Command syntax is output before an error is returned.
    reterr() --- An error message is output before an error is returned.
    sqlbegin()
    {
    db2 set write suspend for db --- Suspend the DB2 database.
    sync
    }
    sqlend()
    {
    db2 set write resume for db ---- Resume the DB2 database.
    }
    getbd() --- Fetch the name of the backup (copy) destination device of AdvancedCopy Manager.
    getdate() --- Fetch the backup (copy) date of AdvancedCopy Manager.
    gettime() --- Fetch the backup (copy) time of AdvancedCopy Manager.
    # main()
    Parameter analysis and raw device check
    # 0) Environmental variable setting
    PATH=$PATH:/usr/bin:/usr/sbin:/opt/FJSVswsts/bin
    # 1) Suspend
    if [ "-a" operand specification ]
    then
    db2 connect to <database name>
    sqlbegin() ----- Suspend the database.
    fi
    # 2) Disk backup (copy) by AdvancedCopy Manager command
    swstbackup $SRC --- Copy the disk.
    # 3) Resume
    if [ "-a" operand specification ]
    then
    sqlend() --- I/O of DB2 is put into the state of suspend.
    db2 terminate -------- Terminate the database.
    fi
    # 4) Acquisition of the backup (copy) destination of AdvancedCopy Manager
    DSTBLK="`getbd $SRC`" --- Fetch a backup volume.
    BKDATE="`getdate $SRC`"
    BKTIME="`gettime $SRC`"
    exit 0

C.4.2 Applying the sample shell scripts 

C.4.2.1 DB information collection 

+Sample shell script update

Update the procedures below of swst_db2_iv to adjust them for actual operations. The following numbers correspond to those in the scripts.

0) Environmental variable setting

1) Acquisition of DB2 table space information

The above procedures 1) to 3) change Oracle account information.

These scripts can operate only on business servers of AdvancedCopy Manager.

C.4.2.2 Backup 

+AdvancedCopy Manager setup

Set up backup volumes so that the raw devide targeted for backup is backed up correctly in AdvancedCopy Manager.

The generations of the backup volumes to be managed are arbitrary.

+Sample shell script update

Update the procedures below of swst_db2_vg_bk to adjust them for actual operations. The following numbers correspond to those in the scripts.

0) Environmental variable setting

1) Notification issued to DB2 of the start of backup

3) Notification issued to DB2 of the stopping of backup

The above procedures 1) and 3) refer to the spdata.lst fil created by swst_db2_iv.

These scripts can operate only on business servers of AdvancedCopy Manager.

+Recording and managing the backup volume name and processing time

After executing a shell script, a backup volume name and the processing time are output in a message. When restoring it, these information is needed. Thus, the backup volume name and processing time output in a message after execution of a shell script must be recorded and managed.

C.4.3 Restore Method 

Use the restore function of AdvancedCopy Manager for restore processing.

C.4.4 Notes about using the sample shell scripts 

+DB2 resource location

Store Oracle data files and files other than data files on separate disks or in separate slices.

+Backup operation of DB2 resources

  1. Database

    1. Back up by the BACKUP DATABASE command of DB2.

    db2 => backup database DB name to target;

    [Database structure]

  2. User table space

    1. The user table space should be created on a RAW device rather than at file system level.
      In case of table space, the table space container is also a part of the backup, and hence please use the provided sample shell scripts.

    2. Using AdvancedCopy Manager the backup operation is performed.

    3. The table spaces targeted for backup, should be selected within the AdvancedCopy Manger's backup unit.
      For example, in case the unit of backup of AdvancedCopy Manger is a LUN, then 1 table space should lie on 1 LUN.

+Recovery of DB2 databases

After DB2 database has stopped, restore the database, and restart it. To recover the database to the latest state, use the recovery function of DB2.

When performing the restore of data, please use the following order
  1. Database

  2. User table space


Contents Index PreviousNext

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