WARNING: JetBackup 4 is set to reach its End-of-Life (EOL) on July 1st, 2024. For More Information, please visit:
JetBackup 4 EOL Announcement.
Create New Hook
You can add a hook to run your script before/after an action.
To create new hook navigate to: "Hooks" and 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
<?php
$http_encoded_data = file_get_contents("php://stdin"); // read the input to the end.
$data=null;
parse_str(urldecode($http_encoded_data), $data); // convert to array.
$data_str = print_r($data, true); // convert array to string.
file_put_contents("/root/testFile", $data_str, FILE_APPEND);
?>
#!/bin/bash
echo Printing Hook Parameters: >> /root/testFile
sIFS=$IFS
declare -A param
while IFS='=' read -r -d '&' key value; do
[[ -z "$key" ]] && continue;
param["$key"]=$value
done <<<$(cat)"&"
IFS=$sIFS;
for i in ${!param[@]}; do
echo key: $i, value: ${param[$i]} >> /root/testFile
done
#!/usr/bin/python
#Python sample for JetBackup hook
import sys
from urlparse import urlparse,parse_qs
http_encoded_data = sys.stdin.read()
data = parse_qs(http_encoded_data)
# print data
f = open("/root/PythonTestFile", 'w')
for k in data:
f.write(""+k+"=>"+data[k][0]+";\n")
f.close()
Hook Name
This will be used internally your convenience.
Hook Position
Choose to run your script Pre/Post your action.
Hook Type
The hook type defines on which action the hook should be executed.
Each hook type receives a different set of parameters by stdin.
Your script can read this data and use it to its own needs.
These are the available action type and the parameters returns for each:
Hook Script
The hook script must be an executable file specified by full path.
For example:
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.