Syncrify » Knowledge base

Document information

Document ID:1893
Subject:Syncrify backup job hooks
Creation date:10/28/11 2:33 PM
Last modified on:1/22/16 12:45 PM


Hooks in Syncrify

Hooks is a mechanism used on Syncrify server to spawn an external script when a new backup job start and/or end. Hooks are supported in Syncrify after build 563.

Follow the steps below to register a hook in Syncrify.

  • Make sure the server is running build 563 or above
  • Stop Syncrify if it is running
  • Locate C:\Syncrify\config\AppConfig.xml file and open it in any editor. Path on Linux is /opt/Syncrify/config/AppConfig.xml
  • Add a new parameter line with the following value

    <parameter name="jobHookScript" type="1" value="path/for/your/script arg1 arg2 arg3"></parameter>

    After modification the file should look something like:

    Backup hook

  • Save the file
  • Restart Syncrify


The value for this parameter line takes a script that runs whenever a new client initiates backup. It contain variables starting with a dollar sign ($). 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.




Add a comment to this document

Do you have a helpful tip related to this document that you'd like to share with other users? Please add it below. Your name and tip will appear at the end of the document text.
Your name:
Your email:
Hide my email address
Verification code:
Enter the verification code you see above more submitting your tip
Tip:Please limit tips to 1000 characters

Navigation

Social Media

Powered by 10MinutesWeb.com