Hook Operations not supported by default
Upon installation, by default the Delphix Engine does not enable hook operations for SQL Server dSources or VDBs. This feature must be enabled by Delphix Support.
Although pre-scripts and post-scripts are an available alternative customization mechanism, Delphix strongly recommends the use of newer, more-capable Hook operations for all new customization work, as opposed to the older, less-capable pre-scripts and post-scripts, which continue to be supported for backward compatibility with older versions of the Delphix virtualization engine.
Some of the advantages of hooks as opposed to pre- and post-scripts...
- Hooks are available for dSources and VDBs; pre- and post-scripts are only available on both VDBs and dSources.
- Pre-script executes after a VDB has been destroyed, so they are not capable of being used to save data or settings from a VDB during a refresh or rewind operation. The corresponding Hooks all execute while the VDB is still available, and can be used to save data or settings from a VDB.
- Hook operations are far more granular, permitting more specific and surgical targeting of operations
- Hooks are facilitated by Operations Templates, which facilitate reuse of code among multiple hooks and multiple VDBs
This topic describes the use of hook operations with dSources created from SQL Server source databases, and virtual databases (VDBs) that are created from SQL Server dSources or other VDBs.
Hooks are Windows Powershell code executed on:
- The Staging target host before or after the manual snapshot of a dSource.
- The VDB target host before and after the provision, refresh, rewind, snapshot, start, or stop of a VDB.
Hooks can be specified in the wizard used during the creation of a VDB, or modified afterwards by navigating to the Configuration > Hooks tab, as shown below. Hooks can also be set using the Delphix command-line interface (CLI) or REST Web API.
Each hook operation represents a user-configurable action that the Delphix virtualization engine will execute. You can configure the custom hook code to fail if they encounter an unexpected error. The failure of a hook operation will cause the enclosing operation to fail.
The Windows environment user for the dSource or VDB runs the "powershell" executable, which runs the specified PowerShell script on the Staging or VDB Target host. The Delphix Engine captures and logs all output of the script and displays it if a failure occurs.
The intent of hook operations are customization of the data contents or configuration of a dataset while it is being manipulated. Actions performed by hooks effectively become an integrated part of the sync operations of a dSource or the provision, refresh, rewind, snapshot, start, or stop actions for that VDB.
Hooks are mainly used for pre- and post-provisioning operations. For example, you can use hooks to:
- Back up test data before refresh and rewind
- Back up data after provisioning
- Reset configuration settings from production to non-production settings after provisioning
- Create logins for dev/qa users who do not have privileges on production databases
- Sync logins on the target that are cloned from production database
- Back up configuration data from database
In the Delphix Engine, there are several different types of dSource and VDB hooks. For more information about dSource hooks, see Customizing SQL Server dSource Management with Hook Operations. For more information about VDB hooks, see Customizing SQL Server VDB Management with Hook Operations.
For more information on Hook Operations, see SQL Server Hook Operation Notes.
Hook Operation Templates
You can use operation templates to store commonly used operations, which allows you to avoid repeated code entry when an operation is applicable to more than a single hook, dSource, or virtual dataset. You can manage templates through the Delphix Admin application.
You can also create templates from existing hooks by exporting the hooks in the Delphix Admin application.
Windows Environment Variables
When a hook is executed, Delphix will set specific Windows environment variables to provide context, such as the name of the current host, the name of the SQL Server instance and port, and the name of the database. For more information, see SQL Server Hook Operation Notes.