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. Query - finding an object descriptor
  6. Query example
Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0

Query example

Here is an example of a query. It starts with populating a query descriptor, which identifies what objects are being searched for. Then it makes the initial query

BSA_Handle                    BsaHandle;
BSA_ObjectOwner               BsaObjectOwner;
BSA_SecurityToken             *security_tokenPtr;
BSA_QueryDescriptor           *query_desc;
BSA_ObjectDescriptor          *object_desc;
BSA_UInt32                    Size;
char                          *envx[3];
char                          ErrorString[512];
char                          msg[1024];
int                           status;
.
.
BSAInit(&BsaHandle, security_tokenPtr, &BsaObjectOwner, envx);
.
.
BSABeginTxn(BsaHandle);

/ *  Populate the query descriptor of the object to be searched for. */
 
query_desc = (BSA_QueryDescriptor *)malloc(sizeof(BSA_QueryDescriptor));
memset(query_desc, 0x00, sizeof(BSA_QueryDescriptor);

query_desc->copyType = BSA_CopyType_BACKUP;
query_desc->objectType = BSA_ObjectType_FILE;
query_desc->objectStatus = BSA_ObjectStatus_ANY;
strcpy(query_desc->objectOwner.bsa_ObjectOwner, "XBSA Client");
strcpy(query_desc->objectOwner.app_ObjectOwner, "XBSA App");
strcpy(query_desc->objectName.pathName, "/xbsa/sample/object1");
strcpy(query_desc->objectName.objectSpaceName, "");
 
object_desc = (BSA_ObjectDescriptor *)malloc(sizeof(BSA_ObjectDescriptor));

/ * Begin searching for objects matching the query criteria.  BSAQueryObject()    *
  * returns the first (most recent) object found.                                 */
 
status = BSAQueryObject(BsaHandle, query_desc, object_desc);
if (status == BSA_RC_SUCCESS) {
    printf("copyId: %d - %d\n", object_desc->copyId.left, object_desc->copyId.right);
} else if (status == BSA_RC_NO_MATCH) {
    sprintf(msg, "WARNING: BSAQueryObject() did not find an object matching the 
       query");
    NBBSALogMsg(BsaHandle, MSWARNING, msg, "Query");
    BSATerminate(BsaHandle);
    exit(status);
} else {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSAQueryObject() failed with error: %s", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Query");
    BSATerminate(BsaHandle);
    exit(status);
}
  
/ * Continue searching for other objects which match the query criteria.  *
  * BSAGetNextQueryObject() should return BSA_RC_NO_MORE_DATA when there  *
  * are not more objects.                                                 */
 
while ((status = BSAGetNextQueryObject(BsaHandle, object_desc)) == BSA_RC_SUCCESS) {
    printf("CopyId: %d.%d\n", object_desc->copyId.left, object_desc->copyId.right);
}
if (status != BSA_RC_NO_MORE_DATA) {
    Size = 512;
    NBBSAGetErrorString(status, &Size, ErrorString);
    sprintf(msg, "ERROR: BSAGetNextQueryObject() failed with error: %s", ErrorString);
    NBBSALogMsg(BsaHandle, MSERROR, msg, "Query");
    BSATerminate(BsaHandle);
    exit(status);
} 
 
/ * End the query transaction.  BSA_Vote_COMMIT and BSA_Vote_ABORT are *
  * equivalent as there is nothing to commit or abort.                 */

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, "Query");
    BSATerminate(BsaHandle);
    exit(status);
}

Feedback

Was this page helpful?
Previous

Querying for an object

Next

Restore - retrieving an object's data

Feedback

Was this page helpful?