Post-backup hooks let you run a script after each backup job completes. The temptation is to use them for everything — verification, monitoring integration, notification, downstream sync. Most of that belongs elsewhere. The hook should do one or two things well and exit clean.
What’s happening
JetBackup hooks fire on events like backup_completed, backup_failed, purge_completed. They run on the cPanel server with the JetBackup user’s privileges and have access to the snapshot details via environment variables or arguments. cPanel itself has prehook and posthook directories under /usr/local/cpanel/3rdparty/.
The hooks run synchronously by default — a slow hook delays the next scheduled job. They run with limited error handling — a hook script that exits non-zero may or may not retry depending on configuration. Treat them as fire-and-forget signals, not as critical-path logic.
How to verify
Inspect existing hooks:
ls /usr/local/jetapps/usr/jetbackup5/hooks/
cat /usr/local/jetapps/usr/jetbackup5/hooks/post-backup.sh
ls /var/cpanel/hooks/
journalctl --since '1 day ago' | grep -i hook
Hooks that haven’t been touched in 2 years are typically forgotten and may be silently failing.
The fix
- Use hooks for short-running notifications: send a metric to your monitoring system, post to a Slack webhook on failure, write a structured log line to your SIEM. Not for actual work.
- Keep hooks idempotent and fast. A
post-backup.shthat takes 30 seconds is too long; aim for under 5. - Verify backups via a separate, scheduled job rather than in a hook. A verification job runs on its own schedule, has its own error handling, and doesn’t block the backup pipeline.
- Log everything the hook does to a dedicated log file (
/var/log/jetbackup-hooks.log). When a hook misbehaves, the only diagnostic is its own log — and stdout/stderr from hooks vanish. - Test hook changes outside production. A hook that exits non-zero unexpectedly can cascade into the next backup job; develop and test in a non-production environment.
Stack Harbor maintains backup hooks and downstream integration as part of environment management.