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

This commit is contained in:
Romain de Laage 2022-09-14 12:58:18 +02:00
parent 4375a38bba
commit f43cc32ac3
No known key found for this signature in database
GPG Key ID: 534845FADDF0C329
6 changed files with 82 additions and 22 deletions

View File

@ -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)

View File

@ -55,10 +55,11 @@ version: 2
extras: extras:
hooks: &foo hooks: &foo
before: backup:
- echo "Hello" before:
after: - echo "Hello"
- echo "kthxbye" after:
- echo "kthxbye"
policies: &bar policies: &bar
keep-daily: 14 keep-daily: 14
keep-weekly: 52 keep-weekly: 52

View File

@ -22,12 +22,13 @@ autorestic exec -b my-backend -- unlock
extras: extras:
healthchecks: &healthchecks healthchecks: &healthchecks
hooks: hooks:
before: backup:
- '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' before:
failure: - '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 "Backup failed for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/fail' failure:
success: - 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup failed for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/fail'
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup successful for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>' success:
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup successful for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>'
locations: locations:
something: something:

View File

@ -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,16 +17,27 @@ locations:
from: /data from: /data
to: my-backend to: my-backend
hooks: hooks:
before: backup:
- echo "One" before:
- echo "Two" - echo "One"
- echo "Three" - echo "Two"
after: - echo "Three"
- echo "Byte" after:
failure: - echo "Byte"
- echo "Something went wrong" failure:
success: - echo "Something went wrong"
- echo "Well done!" success:
- 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

View File

@ -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"
```

View File

@ -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)