Please enter search query.
Search <book_title>...
Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0
Last Published:
2021-01-01
Product(s):
NetBackup & Alta Data Protection (9.0.0.1, 9.0)
- Introduction to NetBackup XBSA
- How to set up the SDK
- Using the NetBackup XBSA interface
- NetBackup XBSA data structures
- NetBackup XBSA environment
- XBSA sessions and transactions
- Creating a NetBackup XBSA application
- How to build an XBSA application
- How to run a NetBackup XBSA application
- API reference
- Function calls
- Function specifications
- Type definitions
- Process flow and troubleshooting
- How to use the sample files
- Support and updates
- Appendix A. Register authorized locations
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); }