Skip to content

Commit 9b8645e

Browse files
authored
docs(hooks): add paragraph about on_failure (#114)
This is also a way of displaying the "expanded" format for command input configuration.
1 parent be11302 commit 9b8645e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/commands/misc/hooks.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ You can use hooks, e.g. to send a notification when a backup has finished:
9090
run-after = ["notify-send 'Backup finished successfully!'"]
9191
```
9292

93+
### Hook command failure
94+
95+
By default, if a hook command fails, `rustic` will log the error and stop. If
96+
you would like `rustic` to continue its process with just a warning in the logs
97+
or nothing, you can use the `on_failure` field.
98+
99+
The `on_failure` field takes `"error"` by default and can take `"warn"` and
100+
`"ignore"` as well.
101+
102+
A first way to write it:
103+
104+
```toml
105+
[backup.hooks]
106+
run-after = [
107+
{ command = "notify-send", args = ["Backup finished successfully!"], on_failure = "warn" },
108+
]
109+
```
110+
111+
An alternative way possible with the toml format:
112+
113+
```toml
114+
[[backup.hooks.run-after]]
115+
command = "notify-send"
116+
args = ["Backup finished successfully!"]
117+
# optional
118+
on_failure = "warn" # possible values are "error" (default), "warn", "ignore"
119+
```
120+
93121
## Use cases
94122

95123
Here are some use cases which might be interesting to use hooks for:

0 commit comments

Comments
 (0)