Hooks
A hook is a script of yours that Salvo runs before or after a job's backup: stop a service, flush a cache, send a notice to your own system.
● available in 0.4.135On the screen
Backup jobs › the job › Hooks opens the drawer Job hooks:
| Hook | If the script fails |
|---|---|
| Before the backup | you choose: If it fails, stop (the backup) or If it fails, go on |
| After the backup | it becomes only a warning in the log; it receives SALVO_STATUS |
The script's output goes to the run log. Maximum time: 600 s by default (up to 6 h).
The script
Checked when saved and again before every backup
The script must be an absolute path to a file that already exists, owned by root, executable, and not writable by group or others, and neither may its folder be. Otherwise the hook is refused.
root@server
chown root:root /root/hooks/before.sh
chmod 700 /root/hooks/before.sh
chmod go-w /root/hooks
Variables the script receives:
| Variable | |
|---|---|
SALVO_HOOK | pre or post |
SALVO_JOB_ID, SALVO_JOB_NAME | the job |
SALVO_RUN_ID | the run |
SALVO_ORIGIN | what started the run |
SALVO_TARGETS | what is being copied |
SALVO_DESTINATION_ID | the destination |
SALVO_LOG | the run log |
SALVO_STATE | Salvo's state folder |
SALVO_STATUS | after the backup only: ok, avisos, falha or abortado |
On the command line
root@server
# the job's hooks
/var/lib/salvo/salvo job-hooks --job ID
# before the backup; if it fails, stop (or: --on-fail continue)
/var/lib/salvo/salvo job-hooks --job ID --add-pre /root/hooks/before.sh --on-fail stop
# after the backup, with a time limit in seconds
/var/lib/salvo/salvo job-hooks --job ID --add-post /root/hooks/after.sh --timeout 300
# remove hook number N, or all of them
/var/lib/salvo/salvo job-hooks --job ID --remove N
/var/lib/salvo/salvo job-hooks --job ID --clear