Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0

Last Published:
Product(s): NetBackup (9.0.0.1, 9.0)
  1. Introduction to NetBackup XBSA
    1.  
      About Introduction to NetBackup XBSA
    2.  
      What is NetBackup XBSA?
    3.  
      What does NetBackup XBSA do?
    4.  
      Terminology
    5.  
      Important concepts
    6.  
      Resources
  2. How to set up the SDK
    1.  
      System requirements
    2. Installing the SDK
      1.  
        Installation requirements
      2.  
        Installation instructions for UNIX platforms
      3.  
        Installation instructions for Windows platforms
    3.  
      Uninstalling the SDK
    4.  
      Configuration
    5.  
      Description of the XBSA SDK package
    6.  
      Library files
    7.  
      Header files
  3. Using the NetBackup XBSA interface
    1.  
      Getting help with the API
    2. NetBackup XBSA data structures
      1.  
        Object data
      2.  
        Object descriptors
      3.  
        Query descriptors
      4. Buffers
        1.  
          Buffer size
        2.  
          Private buffer space
        3.  
          Use of BSA_DataBlock32 in BSASendData()
        4.  
          Use of BSA_DataBlock32 in BSAGetData()
        5.  
          Shared memory
    3. NetBackup XBSA environment
      1.  
        Environment variable definitions
      2.  
        Extended environment variable definitions
    4. XBSA sessions and transactions
      1. Sessions
        1.  
          Initialization and termination
        2.  
          Authentication
      2. Transactions
        1.  
          Backup transaction
        2.  
          Restore transaction
        3.  
          Delete transaction
        4.  
          Query transaction
        5.  
          Media IDs transaction
    5. Creating a NetBackup XBSA application
      1. Initiating a session
        1.  
          Modifying the XBSA environment within a session
        2.  
          Session example
      2. Backup - creating an object
        1.  
          Creating an object
        2.  
          NetBackup object ownership
        3.  
          Creating an empty object
        4.  
          Backup example
      3. Query - finding an object descriptor
        1.  
          Querying for an object
        2.  
          Query example
      4. Restore - retrieving an object's data
        1.  
          Restoring an object
        2.  
          Redirected restore to a different client
        3.  
          Restore example
        4.  
          Multiple object restore
        5.  
          Multiple object restore example
      5. Delete - deleting an object or image
        1.  
          Delete example
      6. Media IDs - obtaining media IDs
        1.  
          Media ID example
      7.  
        Logging and NetBackup
      8.  
        Client in a cluster
      9.  
        Performance considerations
  4. How to build an XBSA application
    1.  
      Getting help
    2.  
      Flags and defines
    3.  
      How to build in debug mode
    4.  
      How to debug the application
    5.  
      Static libraries
    6.  
      Dynamic libraries
    7.  
      End-user configuration
  5. How to run a NetBackup XBSA application
    1. About How to run a NetBackup XBSA application
      1. Creating a NetBackup policy
        1.  
          Selecting a storage unit
        2.  
          Adding new schedules
        3.  
          Adding script files to the files list
        4.  
          Adding new clients
      2.  
        Running a NetBackup XBSA application
      3.  
        Backups and restores initiated by NetBackup (through a script)
      4.  
        Backups and restores from the command line
  6. API reference
    1.  
      Error messages
    2. Function calls
      1.  
        Conventions
    3. Function specifications
      1.  
        BSABeginTxn
      2.  
        BSACreateObject
      3.  
        BSADeleteObject
      4.  
        BSAEndData
      5.  
        BSAEndTxn
      6.  
        BSAGetData
      7.  
        BSAGetEnvironment
      8.  
        BSAGetLastError
      9.  
        BSAGetNextQueryObject
      10.  
        BSAGetObject
      11.  
        BSAInit
      12.  
        BSAQueryApiVersion
      13.  
        BSAQueryObject
      14.  
        BSAQueryServiceProvider
      15.  
        BSASendData
      16.  
        BSATerminate
      17.  
        NBBSAAddToMultiObjectRestoreList
      18.  
        NBBSADeleteImage
      19.  
        NBBSAEndGetMultipleObjects
      20.  
        NBBSAFreeJobInfo
      21.  
        NBBSAGetEnv
      22.  
        NBBSAGetErrorString
      23.  
        NBBSAGetJobId
      24.  
        NBBSAGetJobInfo
      25.  
        NBBSAGetMediaIds
      26.  
        NBBSAGetMultipleObjects
      27.  
        NBBSAGetServerError
      28.  
        NBBSALogMsg
      29.  
        NBBSASetEnv
      30.  
        NBBSAUpdateEnv
      31.  
        NBBSAValidateFeatureId
    4. Type definitions
      1. Enumerated types
        1.  
          BSA_CopyType
        2.  
          BSA_ObjectStatus
        3.  
          BSA_ObjectType
        4.  
          BSA_Vote
        5.  
          Constant values
      2. Data structures
        1.  
          BSA_ApiVersion
        2.  
          BSA_DataBlock32
        3.  
          BSA_ObjectDescriptor
        4.  
          BSA_ObjectName
        5.  
          BSA_ObjectOwner
        6.  
          BSA_QueryDescriptor
        7.  
          BSA_SecurityToken
  7. Process flow and troubleshooting
    1.  
      About Process flow and troubleshooting
    2. Backup
      1. Stream backup process flow description
        1.  
          Stream backup procedure
    3. Restore
      1. Stream restore process flow description
        1.  
          Stream restore procedure
  8. How to use the sample files
    1. What the sample files do
      1. Sample programs
        1.  
          Backup
        2.  
          Restore
        3.  
          Query
        4.  
          Delete
      2.  
        Sample scripts
    2.  
      Description of sample files
    3.  
      How to build the sample programs
  9. Support and updates
    1.  
      About Support and updates
  10. Appendix A. Register authorized locations
    1.  
      Registering authorized locations used by a NetBackup database script-based policy
  11.  
    Index

Backup example

The following example goes through the process of creating an object. It is assumed the transaction has already been started). The BSA_ObjectDescriptor is populated with the values that are associated with the object. Then the DataBlock32 structure is created to receive any restrictions put on the data by the NetBackup Interface. BSACreateObject() is then called to create the object and start the backup process. Once the object is created, this example sends one buffer of data with the BSASendData() call. After the last BSASendData() call, the object is completed with a BSAEndTxn(), which commits the object.

This example only creates one object and only sends one buffer of data. In general, objects take multiple buffers and a transaction can create multiple objects.

BSA_Handle                        BsaHandle;
BSA_ObjectOwner                   BsaObjectOwner;
BSA_SecurityToken                 *security_tokenPtr;
        BSA_DataBlock32           *data_block;
BSA_ObjectDescriptor              *object_desc;
BSA_UInt32                        DataBuffSz;
BSA_UInt32                        Size;
char                              *envx[5];
char                              DataBuff[512];            
char                              ErrorString[512];           
char                              msg[1024];              
int                               status;
.
.             
BSAInit(&BsaHandle, security_tokenPtr, &BsaObjectOwner, envx);
.
.
BSABeginTxn(BsaHandle);

/ * Populate object descriptor of the first object to be backed up. */
 
object_desc = (BSA_ObjectDescriptor *)malloc(sizeof(BSA_ObjectDescriptor));
 
strcpy(object_desc->objectOwner.bsa_ObjectOwner, "XBSA Client");
strcpy(object_desc->objectOwner.app_ObjectOwner, "XBSA App");
strcpy(object_desc->objectName.pathName, "/xbsa/sample/object1");
strcpy(object_desc->objectName.objectSpaceName, "");
strcpy(object_desc->resourceType, "Sample");
strcpy(object_desc->objectDescription,"Sample description of Obj 1");
strcpy(object_desc->objectInfo,"Object 1");
object_desc->copyType = BSA_CopyType_BACKUP;
object_desc->estimatedSize.left = 0;
object_desc->estimatedSize.right = 100;
object_desc->objectType = BSA_ObjectType_FILE; 
 
/ *  Initialize the BSA_DataBlock32 structure. */
 
data_block = (BSA_DataBlock32 *)malloc(sizeof(BSA_DataBlock32));
memset(data_block, 0x00, sizeof(BSA_DataBlock32)); 
/ * Create sample object. If object cannot be created, terminate session. */
 
status = BSACreateObject(BsaHandle, object_desc, data_block);
if (status == BSA_RC_SUCCESS) {
    printf("copyId: %d - %d\n", object_desc->copyId.left, object_desc->copyId.right);
} else {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSACreateObject failed with error: %s", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Backup");
    BSAEndTxn(BsaHandle, BSA_Vote_ABORT);
    BSATerminate(BsaHandle);
    exit(status);
}

/ * For the purposes of this sample, we will assume that the data in the *
  * DataBuff buffer has been populated from reading the data from the object * 
  * being backed up. */
 
strcpy(DataBuff, "This is the sample data that is contained in the sample object that 
is being backed up for the purposes of showing how data can be backed up and 
restored.");
DataBuffSz = strlen(DataBuff); 
 
/ * BSACreateObject sets values in the BSA_DataBlock32 to indicate    *
  * header and trailer requirements. The NetBackup implementation has *
  * no such requirements and are not checked here.  Set the other     *
  * fields of the data_block for the BSASendData call.              */
 
data_block->bufferLen = 512;
data_block->bufferPtr = DataBuff;
data_block->numBytes = DataBuffSz; 
 
/ * Send the data to be backed up.  In normal implementations, BSASendData    *
  * would be in a loop reading the data into the buffer and then sending it   *
  * until all the data of the object has been sent.                       */
 
status = BSASendData(BsaHandle, data_block);
if (status == BSA_RC_SUCCESS) {
    printf("Bytes backed up: %d\n", data_block->numBytes);
} else {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSASendData failed with error: %s\n", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Backup");
    BSAEndTxn(BsaHandle, BSA_Vote_ABORT);
    BSATerminate(BsaHandle);
    exit(status);
}
 
/ *  All data has been sent for the object.  */
 
status = BSAEndData(BsaHandle);
if (status != BSA_RC_SUCCESS) {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSAEndData failed with error: %s", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Backup");
    BSAEndTxn(BsaHandle, BSA_Vote_ABORT);
    BSATerminate(BsaHandle);
    exit(status);
}
 
/ *  End the backup transaction and commit the object.  */
 
status = BSAEndTxn(BsaHandle, BSA_Vote_COMMIT);
if (status != BSA_RC_SUCCESS) {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSAEndTxn failed with error: %s", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Backup");
    BSATerminate(BsaHandle);
    exit(status);
}