Skip Headers
Oracle® Fusion Middleware User's Guide for Oracle B2B
11g Release 1 (11.1.1.7)

Part Number E10229-13
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

23 Scripts for Archiving and Restoring Data

This chapter describes how to archive and restore B2B business messages using SQL scripts.

This chapter contains the following topics:

See Chapter 7, "Importing and Exporting Data," for information on importing and exporting design-time data.

23.1 Introduction to Archiving and Restoring B2B Business Messages

Oracle B2B uses Oracle Data Pump, an Oracle Database 11g feature that enables fast bulk data and metadata movement, to archive B2B runtime instance data in Oracle databases.Foot 1 

You can specify criteria for archiving (and optionally purging) business messages based on start date, end date, and message state. The targeted business messages are marked with JOB_ID, a column in the B2B runtime tables that is used to synchronize archive and purge activity. B2B invokes the Data Pump PL/SQL API using JOB_ID. Hence, when you archive business messages, all the associated tables are also archived. Archived business messages can also be restored by using the Data Pump to import the runtime data into Oracle B2B (Oracle Metadata Service repository) and accessing it through B2B reports.

23.2 Archiving B2B Business Messages

To archive business messages, set up the archive directory and permissions and then run the archive procedure. The procedure provides an option to purge the archived rows.

To set up the archive directory and permissions:

  1. On the computer running the database, create a directory for the archive file. For example,

    mkdir /tmp/archive
    
  2. Give permissions to this directory so that the database process can write to it. For example,

    chmod 777 /tmp/archive
    
  3. Log in to the database as sysdba.

    sqlplus /as sysdba
    
  4. Set up B2B_EXPORT_DIR.

    SQL> create or replace directory B2B_EXPORT_DIR as '/tmp/import'
    
  5. Grant the SOA schema user (for example, b2b_soainfra) permission for the export.

    SQL> grant read, write on directory B2B_EXPORT_DIR to b2b_soainfra;
    SQL> grant exp_full_database to b2b_soainfra;
    

To archive, with an option to purge:

Set up the archive directory and permissions before using the following PL/SQL API.

  1. Log in as the SOA schema user.

    $ sqlplus b2b_soainfra/password
    
  2. Execute the archive procedure, for example,

    SQL> exec b2b_archive_procedure('21-JAN-2008','28-JAN-2008','MSG_COMPLETE','JAN.dmp','N');
    

    The signature of the procedure is

    b2b_archive_procedure(fromDate, toDate, messageState, fileName, should_purge);
    

    Table 23-1 lists the parameters for the b2b_archive_procedure API.

    Table 23-1 b2b_archive_procedure Parameters

    Parameter Example Description

    fromDate

    21-JAN-2008

    Starting date for archival, DD-MON-YYYY

    toDate

    28-JAN-2008

    Ending date for archival, DD-MON-YYYY

    messageState

    MSG_COMPLETE

    State of the business message. The MSG_COMPLETE state is typically archived. Other possible states are MSG_INVALID, MSG_CONTINUE_PROCESS, MSG_COLLAB_WAIT, MSG_PROCESS_ACK, MSG_SEND_ACK, MSG_WAIT_ACK, MSG_ERROR, MSG_WAIT_TRANSMIT, MSG_SEND_EXP, MSG_PROCESS_EXP, MSG_ABORTED, MSG_TRANSMITFAILED, MSG_WAIT_FA, MSG_SEND_FA, MSG_WAIT_BATCH

    fileName

    JAN.dmp

    Name of the archive file to be created by the database. Ensure that a file with this name does not exist in the archive directory.

    should_purge

    N

    Y removes the archived rows. The default is N.


23.3 Restoring B2B Business Messages

To restore business messages, set up the import directory and permissions and then run the restore procedure.

To set up the import directory and permissions:

  1. On the PC running the database, create a directory for the import file.

    mkdir /tmp/import
    
  2. Give permissions to this directory so that the database process can read from it.

    chmod 777 /tmp/import
    
  3. Log in to the database as sysdba.

    sqlplus /as sysdba
    
  4. Set up B2B_IMPORT_DIR.

    SQL> create or replace B2B_IMPORT_DIR as '/tmp/import'
    
  5. Grant the SOA schema user (b2b_soainfra) permission for the import.

    SQL> grant read, write on directory B2B_IMPORT_DIR to b2b_soainfra;
    SQL> grant imp_full_database to b2b_soainfra;
    

To restore business messages:

Set up the import directory and permissions before using the following PL/SQL API.

  1. Log in as the SOA infra schema user.

    $ sqlplus soa_infra_user/password
    
  2. Execute the import procedure, for example

    SQL> exec b2b_restore_procedure('JAN.dmp');
    

    The signature of the procedure is

    b2b_restore_procedure(fileName)
    

    Use the Reports tab to search for and display the imported data.



Footnote Legend

Footnote 1: For non-Oracle databases, external database archiving tools can be used to export and import runtime data.