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

Appendix B 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 databases.

B.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.

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 

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. 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 B.1 Backup method]

B.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 B.2 Restore method]

B.3 Sample Shell Scripts 

B.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_fs_bk

Oracle transaction, general file transaction

File system

3

Backup

swst_or_rd_bk

Oracle transaction

Raw device

B.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.

For Oracle 9i or later, replace the svrmgrl command used in swst_or_iv with the sqlplus command.
  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
    
    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;
    
    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;
    
    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
     
  4. Processing outline

    #!/bin/sh
    reterr() --- An error message is output before an error is returned.
    sqldata()
    {
    sqlplus AAA/BBB <<!
    SELECT --- Acquire Oracle table space information.
    }
    sqllog()
    {
    svrmgrl <<!
    show --- Acquire Oracle log information.
    }
    sqlcont()
    {
    svrmgrl <<!
    show --- Acquire Oracle control 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
    exit 0

B.3.1.2 File system backup

swst_or_fs_bk run AdvancedCopy Manager to back up an Oracle database on the file system and business data using general files.

Business data is copied to the backup volumes of AdvancedCopy Manager. These scripts applies to steps 2 to 5 in "Backup procedure."

  1. Start

    swst_or_fs_bk  {-a | -i} <mount-point-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.
    mount-point-name:  Specify the name of the mount point targeted for backup.
  3. Example of using swst_or_fs_bk

    While business is active, back up /gyoumu_db in which an Oracle database is located.
    #  swst_or_fs_bk  -a  /gyoumu_db
    swst_or_fs_bk  completed. ( /gyoumu_db -> /dev/dsk/c1t3d0s2/gyoumu_db_SW at 23:00 on 1999.11.01 )
  4. Processing outline of swst_or_fs_bk

    #!/bin/sh
    usage() --- Command syntax is output before an error is returned.
    reterr() --- An error message is output before an error is returned.
    chkmp() --- Check for a mount point
    get_mp_blk() --- Conversion from a mount point to a device
    getfs() --- Conversion from a mount point to a file system type
    sqlbegin()
    {
    sqlplus AAA/BBB <<!
    alter system switch logfile;
    alter system flush shared_pool;
    alter tablespace CCC begin backup; --- Notify Oracle of the start of backup.
    }
    sqlend()
    {
    sqlplus AAA/BBB <<!
    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 mount point 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 $UDBLK --- 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
    BDBLK="`getbd $UDBLK`" --- Fetch a backup volume as a character device.
    BDDATE="`getdate $UDBLK`"--- Fetch the backup date.
    BDTIME="`gettime $UDBLK`"--- Fetch the backup time.
    exit 0

B.3.1.3 Raw device backup 

swst_or_rd_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 5 in "Backup procedure."

  1. Start

    swst_or_rd_bk  {-a | -i}  <device 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.
    device name:  Specify the name of the raw device partition targeted for backup.
  3. Example of using swst_or_rd_bk

    While business is active, back up /dev/rdsk/c0t0d0s0 in which an Oracle database is located.
    #  swst_or_rd_bk  -a  /dev/rdsk/c0t0d0s6
    swst_or_rd_bk  completed. ( /dev/rdsk/c0t0d0s6 -> /dev/rdsk/c1t3d0s2 at 23:01 on 1999.11.01 )
  4. Processing outline of swst_or_rd_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 AAA/BBB <<!
    alter system switch logfile;
    alter system flush shared_pool;
    alter tablespace CCC begin backup; --- Notify Oracle of the start of backup.
    }
    sqlend()
    {
    sqlplus AAA/BBB <<!
    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.
    DST="`get_blk_chr $DSTBLK`"
    BKDATE="`getdate $SRC`"
    BKTIME="`gettime $SRC`"
    exit 0

B.3.2 Applying the sample shell scripts 

B.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.

B.3.2.2 File system backup 

+AdvancedCopy Manager setup

Set up backup volumes so that the mount point 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_fs_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

2) Notification issued to Oracle of the stopping of backup

The above procedures 1) and 3) refer to the spdata.bgn file and spdata.end file created by swst_or_iv.

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

B.3.2.3 Raw device 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_rd_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

2) Notification issued to Oracle of the stopping of backup

The above procedures 1) and 3) refer to the spdata.lst file, spdata.srt file, spdata.bgn file, spdata.end file, splog.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.

B.3.3 Restore Method 

B.3.3.1 File system 

Use the restore function of AdvancedCopy Manager for restore processing.

B.3.3.2 Raw device 

Use the restore function of AdvancedCopy Manager for restore processing.

B.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.


Contents Index PreviousNext

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