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. Initiating a session
  6. Session example
Veritas NetBackup™ DataStore SDK Programmer's Guide for XBSA 1.1.0

Session example

The following example sets up a session and begins a transaction. It sets up the XBSA environment, a BSA_ObjectOwner structure, and a BSA_SecurityToken. The security token is NULL because the NetBackup XBSA interface does not use this security method. The session is initiated by a BSAInit() call that returns a BSA_Handle. This handle is then used when a transaction begins and for all XBSA function calls within the session. Within the session, the XBSA environment is modified to change the NBBSA_CLIENT_HOST. Lastly a transaction is started.

BSA_Handle                    BsaHandle;
BSA_Obje ctOwner              BsaObjectOwner;
BSA_SecurityToken             *security_tokenPtr;
BSA_UInt32                    Size;       
char                          *envx[3];          
char                          ErrorString[512]; 
char                          msg[1024];        
int                           status;            
                              
/ * Allocate memory for the XBSA environment variable array. */
envx[0] = malloc(40);
envx[1] = malloc(40);

/ * Populate the XBSA environment variables for this session.
  * Normally the BSA_SERVICE_HOST would not be hard coded like this but
  * would be retrieved via a parameter or environment variable.
  */
strcpy(envx[0], "BSA_API_VERSION=1.1.0");
strcpy(envx[1], "BSA_SERVICE_HOST=server_host");
envx[2] = NULL; 

/ * The NetBackup XBSA Interface does not use the security token. */
 
security_tokenPtr = NULL; 

/ * Populate the object owner structure. */

strcpy(BsaObjectOwner.bsa_ObjectOwner,"XBSA Client");
strcpy(BsaObjectOwner.app_ObjectOwner,"XBSA App"); 

/ * Initialize an XBSA session. */
status = BSAInit(&BsaHandle,NULL,&BsaObjectOwner,envx);
if (status != BSA_RC_SUCCESS) {
   Size = 512;
   NBBSAGetErrorString(status, &Size, ErrString);
   printf("ERROR: BSAInit failed with error: %s\n", ErrString);
   exit(status);
}

/ * Set the hostname of the client for the next transaction.  */
NBBSASetEnv(BsaHandle, "NBBSA_CLIENT_HOST", "client_host");

/ * Begin a transaction.  If it fails, terminate the session. */
status = BSABeginTxn(BsaHandle);
if (status != BSA_RC_SUCCESS) {
   Size = 512;
   NBBSAGetErrorString(status, &Size, ErrorString);
   sprintf(msg, "ERROR: BSABeginTxn failed with error: %s", 
       ErrorString);
   NBBSALogMsg(BsaHandle, MSERROR, msg, "Backup");
   BSATerminate(BsaHandle);
   exit(status);
}

Feedback

Was this page helpful?
Previous

Modifying the XBSA environment within a session

Next

Backup - creating an object

Feedback

Was this page helpful?