Overview
With the JetBackup Hooks System, you can trigger custom scripts when JetBackup executes an task on specific hook points. For example, you could use hooks to notify you through your preferred application when a backup job starts, completes or fails.
Create New Hook
To create a new hook, click on "+ Create New Hook".
Example configuration page for hooks:
Here's a sample script that goes through each parameter passed from the hook and prints the key(parameter name) and value of each parameter to a "testFile".
#!/usr/bin/php
// PHP sample for JetBackup hook
// All Hook Args are stored in $argv
<?php
for ($i = 1; $i < sizeof($argv); $i++) {
$data = "Arg " . $i . ": " . $argv[$i] . "\r\n"; //Format Data
file_put_contents("/root/testFile", $data, FILE_APPEND); //Append each arg to file
}
?>
#!/bin/bash
# Hook Args are passed into $@
echo Printing Hook Parameters: >> /root/testFile
argArray=( "$@" ) # Storing args in new array for printing
for i in "${!argArray[@]}"; do
echo "Arg $i: ${argArray[$i]}" >> /root/testFile
done
#!/usr/bin/python
#Python sample for JetBackup 5 Hook
import sys
f = open("/root/PythonTestFile", 'w')
f.write("Printing Hook Parameters:\n")
for i in range(1,len(sys.argv)):
f.write("Arg "+str(i)+": "+sys.argv[i]+"\n")
f.close()
Hook Name
This will be used internally your convenience.
Hook Position
Choose to run your script Pre/Post selected task.
Hook Type
The hook type defines which task the hook should be executed.
Each hook type receives a different set of arguments. Your script can fetch this data and use it to its own needs.
These are the available action type and the arguments that are passed:
Backup Hook
Backup Account Hook
Clone Hook
Clone Account Hook
Restore Hook
Download Hook
Reindex Hook
Hook Script
The hook script must be an executable file specified by full path. For example:
/hooks/pre-backup.sh
If it’s not an executable script, such as regular PHP file you should specify the executable to run your script. For example:
/usr/bin/php /hooks/pre-backup.php
This executable should exit with success (0) if it executed successfully, Otherwise, if it fails, it should exit with an error code - other than 0.
Hook Settings
Enable/Disable Hook
Click on Disable/Enable Hook to Disable/Enable your Hook.
Manage Hook
Click on Manage Hook to modify Hook settings.
Delete Hook
Click on Delete Hook to Delete your Hook permanently.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.