Update docs to explain restore hooks feature and add a migration guide

pull/213/head
Romain de Laage 2 years ago
parent 4375a38bba
commit f43cc32ac3
No known key found for this signature in database
GPG Key ID: 534845FADDF0C329

@ -45,6 +45,7 @@
> >
> [0.x → 1.0](/migration/0.x_1.0) > [0.x → 1.0](/migration/0.x_1.0)
> [1.4 → 1.5](/migration/1.4_1.5) > [1.4 → 1.5](/migration/1.4_1.5)
> [1.7 → 1.8](/migration/1.7_1.8)
[Examples](/examples) [Examples](/examples)
[Docker](/docker) [Docker](/docker)

@ -55,6 +55,7 @@ version: 2
extras: extras:
hooks: &foo hooks: &foo
backup:
before: before:
- echo "Hello" - echo "Hello"
after: after:

@ -22,6 +22,7 @@ autorestic exec -b my-backend -- unlock
extras: extras:
healthchecks: &healthchecks healthchecks: &healthchecks
hooks: hooks:
backup:
before: before:
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Starting backup for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/start' - 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Starting backup for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/start'
failure: failure:

@ -1,8 +1,8 @@
# Hooks # Hooks
If you want to perform some commands before and/or after a backup, you can use hooks. If you want to perform some commands before and/or after a backup or restore, you can use hooks.
They consist of a list of commands that will be executed in the same directory as the target `from`. They consist of a list of commands that will be executed in the same directory as the config file or in the `dir` directory if configured.
The following hooks groups are supported, none are required: The following hooks groups are supported, none are required:
@ -17,6 +17,7 @@ locations:
from: /data from: /data
to: my-backend to: my-backend
hooks: hooks:
backup:
before: before:
- echo "One" - echo "One"
- echo "Two" - echo "Two"
@ -27,6 +28,16 @@ locations:
- echo "Something went wrong" - echo "Something went wrong"
success: success:
- echo "Well done!" - echo "Well done!"
restore:
dir: /var/www/html
before:
- echo "Let's restore this backup!"
after:
- echo "Finished to restore"
failure:
- echo "A problem has been encountered :("
success:
- echo "Successfully restored!"
``` ```
## Flowchart ## Flowchart

@ -0,0 +1,45 @@
# Migration from `1.7` to `1.8`
## Config files
- The config version have been changed
- You can now configure restore hooks
See detailed instructions below.
## Config Version
The version field of the config file has been changed from `2` to `3`.
## Hooks
Since `1.8` both backup and restore hooks are possible.
For this reason, backup hooks have been moved one layer deeper, you have to move them in a `backup` object.
Before:
```yaml
locations:
l1:
# ...
from: /foo/bar
hooks:
before:
- pwd
```
After:
```yaml
locations:
l1:
# ...
from: /foo/bar
hooks:
backup:
before:
- pwd
restore:
after:
- echo "My super restore hook"
```

@ -2,3 +2,4 @@
- [From 0.x to 1.0](/migration/0.x_1.0) - [From 0.x to 1.0](/migration/0.x_1.0)
- [From 1.4 to 1.5](/migration/1.4_1.5) - [From 1.4 to 1.5](/migration/1.4_1.5)
- [From 1.7 to 1.8](/migration/1.7_1.8)

Loading…
Cancel
Save