If you want to perform some commands before and/or after a backup, you can use hooks.
They consist of a list of commands that will be executed in the same directory as the target
The following hooks groups are supported, none are required:
.autorestic.yml1locations:2 my-location:3 from: /data4 to: my-backend5 hooks:6 before:7 - echo "One"8 - echo "Two"9 - echo "Three"10 after:11 - echo "Byte"12 failure:13 - echo "Something went wrong"14 success:15 - echo "Well done!"
successhook if no errors were found
failurehook if at least one error was encountered
before hook encounters errors the backup and
after hooks will be skipped and only the
failed hooks will run.
All hooks are exposed to the
AUTORESTIC_LOCATION environment variable, which contains the location name.
success hooks have access to additional information with the following syntax:
Every type of metadata is appended with both the name of the backend associated with and the number in which the backends where executed.
Assuming you have a location
bar that backs up to a single backend named
foo you could expect the following env variables: