User Guide Home   >   Server Advanced Features   >   Hooks



Hooks

Hooks is a mechanism used on Syncrify Server to spawn an external script when a new backup job starts and/or ends. Note: Hooks are supported in Syncrify after build 563.



Register a Hook in Syncrify

The value for this parameter line takes a script that should be run whenever a new client initiates backup. It contains variables starting with a dollar sign ($). The following table describes the meaning of each variable:

Variable name Description
$EVENT This value can either be true or false It will be true when the script is called when a job is started and false when the script is called when job is complete.
$CLIENT_IP IP address of the client
$CLIENT_BUILD_NO Build number of the client
$PROFILE Name of the profile. If the profile name contains a space, it will be replaced by an underscore.
$USER User's email address
$FILE_COUNT Total files. This value is always 0 when $EVENT is true.
$BYTE_COUNT Total bytes. This value is always 0 when $EVENT is true
$JOB_ID An integer representing the job. This number is repeated after Syncrify server is rebooted



Design consideration

Syncrify is a multi-threaded server. Meaning more than one client can send backup jobs simultaneously. Therefore, you should write your script considering that it can be called simultaneously.



Sample Scripts

Following examples assume the value for jobHookScript parameter is set to:

<parameter name="jobHookScript" type="1" value="C:/temp/testHook.bat $EVENT $CLIENT_IP $CLIENT_BUILD_NO $PROFILE $USER $FILE_COUNT $BYTE_COUNT"></parameter>

Example 1

echo %1 %2 %3 %4 %5 %6 %7 %8 %9 >> c:\temp\hookResult.txt

This script will write space separated data to C:\temp\hookResult.txt

Example 2

if "%1"=="false" goto finish
start c:\Data\JobStarted.exe %2 %4 %5
goto done

:finish
start c:\Data\JobCompleted.exe %2 %4 %5

:done

This example runs JobStarted.exe when a job starts and JobCompleted.exe when a job ends. In both cases, the .EXE file is passed 3 parameters: Client's IP address, Profile name and user's login.