Ransomware attackers specifically target and attempt to destroy backup systems to increase the probability of payment. Hardening your system is critical. Please ensure you have reviewed your platform security using the Security Hardening Checklist
Cohesity

COHESITY Documentation

Explore our documentation to get started, discover products & new features, access troubleshooting guides, register sources, platforms support.

Products
Data Security Alliance
Visit Cohesity.com
Demos
Support
Blogs
Developers
Partner Portals
Cohesity Community
© 2026 Cohesity, Inc. All Rights Reserved.
Terms of Use|
Privacy Policy|
Legal|
  1. Home
  2. Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0
  3. Using the NetBackup XBSA interface
  4. Creating a NetBackup XBSA application
  5. Backup - creating an object
  6. Backup example
Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0

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);
}

Feedback

Was this page helpful?
Previous

Creating an empty object

Next

Query - finding an object descriptor

Feedback

Was this page helpful?