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 from.
The following hooks groups are supported, none are required:
beforeafterfailuresuccess1linklocations:
2link my-location:
3link from: /data
4link to: my-backend
5link hooks:
6link before:
7link - echo "One"
8link - echo "Two"
9link - echo "Three"
10link after:
11link - echo "Byte"
12link failure:
13link - echo "Something went wrong"
14link success:
15link - echo "Well done!"
before hookafter hooksuccess hook if no errors were foundfailure hook if at least one error was encounteredIf the 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.
The after and success hooks have access to additional information with the following syntax:
1link$AUTORESTIC_[TYPE]_[I]
2link$AUTORESTIC_[TYPE]_[BACKEND_NAME]
Every type of metadata is appended with both the name of the backend associated with and the number in which the backends where executed.
SNAPSHOT_IDPARENT_SNAPSHOT_IDFILES_ADDEDFILES_CHANGEDFILES_UNMODIFIEDDIRS_ADDEDDIRS_CHANGEDDIRS_UNMODIFIEDADDED_SIZEPROCESSED_FILESPROCESSED_SIZEPROCESSED_DURATIONAssuming you have a location bar that backs up to a single backend named foo you could expect the following env variables:
1link$AUTORESTIC_LOCATION=bar
2link$AUTORESTIC_FILES_ADDED_0=42
3link$AUTORESTIC_FILES_ADDED_FOO=42
Home Quick Start Installation Configuration Upgrade