Skip to main content

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.135

On the screen​

Backup jobs › the job › Hooks opens the drawer Job hooks:

HookIf the script fails
Before the backupyou choose: If it fails, stop (the backup) or If it fails, go on
After the backupit 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_HOOKpre or post
SALVO_JOB_ID, SALVO_JOB_NAMEthe job
SALVO_RUN_IDthe run
SALVO_ORIGINwhat started the run
SALVO_TARGETSwhat is being copied
SALVO_DESTINATION_IDthe destination
SALVO_LOGthe run log
SALVO_STATESalvo's state folder
SALVO_STATUSafter 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