autorestic/docs/markdown/location/hooks.md

43 lines
916 B
Markdown
Raw Normal View History

2020-05-17 12:52:30 +00:00
# Hooks
2021-04-15 22:26:57 +00:00
If you want to perform some commands before and/or after a backup, you can use hooks.
2021-05-06 13:55:32 +00:00
They consist of a list of commands that will be executed in the same directory as the target `from`.
The following hooks groups are supported, none are required:
- `before`
- `after`
- `failure`
- `success`
2020-05-17 12:52:30 +00:00
```yml | .autorestic.yml
locations:
my-location:
from: /data
to: my-backend
hooks:
before:
2021-05-06 13:55:32 +00:00
- echo "One"
- echo "Two"
- echo "Three"
2020-05-17 12:52:30 +00:00
after:
2021-05-06 13:55:32 +00:00
- echo "Byte"
failure:
- echo "Something went wrong"
success:
- echo "Well done!"
2020-05-17 12:52:30 +00:00
```
2021-05-06 13:55:32 +00:00
## Flowchart
1. `before` hook
2. Run backup
3. `after` hook
4. - `success` hook if no errors were found
- `failure` hook if at least error was encountered
If the `before` hook encounters errors the backup and `after` hooks will be skipped and only the `failed` hooks will run.
2020-05-17 12:52:30 +00:00
> :ToCPrevNext