Skip to content

[Feature Request] Expose more environment variables to hooks #1578

@Chostakovitch

Description

@Chostakovitch

Hi everyone !

Since #1518, rustic gives hooks a bit of context for backups, but I think it would be nice to have that for other commands. My use case is especially monitoring/alerting.

However I feel that too much variables would result in too much specific code and difficulties to document/use.

So I propose the following, available for all hooks :

  • RUSTIC_COMMAND: command which triggered the hook (prune, snapshots, etc)
  • RUSTIC_HOOK_COMMAND: command of the current hook (as a string)

Additionally, run-failed hooks could benefit from:

  • RUSTIC_FAILED_COMMAND: command which has failed
  • RUSTIC_FAILED_COMMAND_RC: return code of the failed command

Example use case : ability for the hook to take action depending on the command, e.g. issuing a warning for certain failures, ignoring others, while giving sufficient context so that alerts are meaningful (e.g. a cat failure is not the same as a prune failure).

Maybe each *_COMMAND could be separated in two variables: verb and args.
I feel this is generic enough to serve a lot of use cases.

I know nothing about Rust, but @rdelaage proposed to help if it makes sense.

What do you think ? @aawsome ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configArea: Related to the config file functionality and formatC-enhancementCategory: New feature or requestE-help-wantedCall for participation: Help is requested to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions