Writing Custom Scripts

To coordinate application activity on VMs included into a protection domain before and after a PD snapshot is taken, you can run custom scripts. A custom script performs pre-freeze operations, takes the PD snapshot, and finally performs post-thaw operations.

Important

Veeam does not provide support for cases related to custom scripts.

You can use any programming language to write a script. However, you must specify the used interpreter in the shebang line, for example: #!/usr/bin/python3. For more information, see Appendix A. Custom Script Samples.

Note

You cannot use binary files for custom scripts.

While writing custom scripts, use the following arguments:

Argument

Description

--clusterId

[Applies only to Prism Central deployment] ID of a cluster where the protection domain is configured.

--pdName

Name of a protection domain for which a PD snapshot is created.

--jobName

Name of a job that runs the script.

--logDir

Path to a folder where script logs are stored.

--logLevel

Level of logging.

To specify parameters required for connecting to the Nutanix AHV cluster where VMs included into the protection domain are running, use environment variables such as in the following example:

nutanixClusterIp = os.getenv('NUTANIX_CLUSTER_ADDRESS')
nutanixLogin = os.getenv('NUTANIX_CLUSTER_LOGIN')
nutanixPass = os.getenv('NUTANIX_CLUSTER_PASSWORD')

To specify parameters required for connecting to the Prism Central where VMs included into the protection domain are running, use environment variables such as in the following example:

nutanixPrismCentralIp = os.getenv('NUTANIX_PRISM_CENTRAL_ADDRESS')
nutanixLogin = os.getenv('NUTANIX_CLUSTER_LOGIN')
nutanixPass = os.getenv('NUTANIX_CLUSTER_PASSWORD')

You can find script logs in the custom_script.log file stored in the /var/log/nxbackupagent/Backup/<job_name_job_uuid>/<pd_name>/ folder on the backup appliance. The file also contains a JSON string that includes the script execution status, an error description (if any) and an identifier of the PD snapshot if it has been created, for example:

  • Script execution succeeded:

Result: {"status": "Success", "errorMessage": "", "oob_schedule_id": 7885270}

  • Script execution failed:

Result: {"status": "Failed", "errorMessage": "Unable to get vm_id list for Protection Domain='VeeamBackupProtection': Authentication failed.", "oob_schedule_id": ""}

  • Script execution completed with a warning:

Result: {"status": "Warning", "errorMessage": "Pre-freeze took more time than expected", "oob_schedule_id": "44509"}

 

Tip

You can track the script execution progress on the Session Logs page in the backup appliance web console. Alternatively, you can download log files to your local machine.

Page updated 8/21/2024

Page content applies to build 12.7.0.172