Hooks
A volume can declare a per-volume hook — a command the agent
runs to nudge an external tool when the volume’s content changes. Squirrel stays
tool-agnostic: it never learns what the command does (a backup with
kopia/restic, an rclone copy, a shell script — all the same to squirrel). It
exec’s the command without a shell, passes context through environment
variables, and records only the generic outcome (exit code, timestamps).
[volumes.pictures.hook]command = ["kopia", "snapshot", "create", "."]timeout = "30m" # optional, defaults to 1hinterval = "24h" # optional — also fire on this cadence (see below)Two triggers
Section titled “Two triggers”A hook fires on two triggers, both reusing the same command:
- on change — after every successful index run on the volume (which the agent
runs on the
index_every/sync_everycadence). This answers “is the latest content backed up?”. It keys off content settling, not a sync to a remote, so a volume needs nosync_todestination for the hook to be useful. - on interval — every
interval, regardless of whether anything changed. This answers “is the existing backup still intact?”. Verification is orthogonal to change — bitrot happens to static data — so re-checks have to run on a clock. Omitintervalto fire on-change only.
Environment passed to the command
Section titled “Environment passed to the command”The command tells the two triggers apart via SQUIRREL_TRIGGER, so a single
command can back up on change and verify on interval:
| Variable | Meaning |
|---|---|
SQUIRREL_VOLUME | volume name |
SQUIRREL_PATH | absolute volume path |
SQUIRREL_RUN_ID | the index run that triggered the hook (empty on the interval trigger) |
SQUIRREL_CHANGED | true/false — whether the run observed changes (so the command can cheaply no-op); always false on the interval trigger |
SQUIRREL_TRIGGER | change or interval |
Because the command is exec’d without a shell, the volume path is never
string-concatenated into a command line. If you want shell features, make the
command ["sh", "-c", "…"] yourself.
Best-effort
Section titled “Best-effort”A hook is best-effort: a hook failure or timeout never fails or blocks the run that triggered it, and overlapping invocations for the same volume are skipped rather than stacked.
Recorded outcomes are visible via squirrel hooks and the TUI’s Hooks tab:
squirrel hookssquirrel hooks --volume pictures --limit 5