restic: Add notification
Notifies double for each prune/check run which may need to be fixed. Also custom notification contents cannot currently be passed. Lastly, we should put identifying information into the notification body (such as the hostname/container name for which the notification is relevant).
This commit is contained in:
parent
003cf64a77
commit
fab6f5ff7c
3 changed files with 84 additions and 9 deletions
|
|
@ -55,3 +55,15 @@ restic_check_args: --read-data-subset=5%
|
|||
The default check cronjob schedule and arguments:
|
||||
Check the repository integrity every day at 5:15 AM and in addition to structural checks,
|
||||
read 5 randomly chosen % for a data integrity check.
|
||||
|
||||
```yaml
|
||||
restic_notify_success:
|
||||
restic_notify_failure:
|
||||
restic_notify_exit:
|
||||
```
|
||||
|
||||
If restic should notify the user on success/failure/exit (i.e. any outcome process finish).
|
||||
Defaults to no notifications.
|
||||
Uses Apprise and thus takes an [apprise URL](https://github.com/caronc/apprise/wiki) in the form of `ntfy://my-ntfy-channel`.
|
||||
Setting one of these configures _both_ the prune and the check to notify the user if either is done,
|
||||
so currently any success (failure/exit) notification would be doubled for each sucess (failure/exit).
|
||||
|
|
|
|||
|
|
@ -12,11 +12,16 @@ restic_forget_args: --prune --keep-last 14 --keep-daily 2 --keep-weekly 2
|
|||
restic_check_cron: 0 30 4 * * SUN
|
||||
restic_check_args: --read-data-subset=15%
|
||||
|
||||
# backup target
|
||||
restic_repo: /opt/stack_restic_backup
|
||||
restic_pass: my-restic-pass
|
||||
restic_s3_key:
|
||||
restic_s3_secret:
|
||||
|
||||
restic_notify_success:
|
||||
restic_notify_failure:
|
||||
restic_notify_exit:
|
||||
|
||||
# S3 example
|
||||
# restic_repo: s3.eu-central-1.wasabisys.com/myrepo
|
||||
# restic_pass: <restic-pass>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,32 @@ services:
|
|||
prune:
|
||||
image: "mazzolino/restic:{{ restic_version }}"
|
||||
hostname: docker
|
||||
networks:
|
||||
- restic_notify
|
||||
depends_on:
|
||||
- notify_exit
|
||||
environment:
|
||||
- "TZ={{ restic_tz }}"
|
||||
- "SKIP_INIT={{ not restic_auto_init }}"
|
||||
- "RUN_ON_STARTUP=true"
|
||||
- "PRUNE_CRON={{ restic_prune_cron }}"
|
||||
- "RESTIC_FORGET_ARGS={{ restic_forget_args }}"
|
||||
- "RESTIC_REPOSITORY={{ restic_repo }}"
|
||||
- "RESTIC_PASSWORD={{ restic_pass }}"
|
||||
- "AWS_ACCESS_KEY_ID={{ restic_s3_key }}"
|
||||
- "AWS_SECRET_ACCESS_KEY={{ restic_s3_secret }}"
|
||||
TZ: "{{ restic_tz }}"
|
||||
SKIP_INIT: "{{ not restic_auto_init }}"
|
||||
RUN_ON_STARTUP: "true"
|
||||
PRUNE_CRON: "{{ restic_prune_cron }}"
|
||||
RESTIC_FORGET_ARGS: "{{ restic_forget_args }}"
|
||||
RESTIC_REPOSITORY: "{{ restic_repo }}"
|
||||
RESTIC_PASSWORD: "{{ restic_pass }}"
|
||||
AWS_ACCESS_KEY_ID: "{{ restic_s3_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}"
|
||||
{% if restic_notify_success != None %}
|
||||
POST_COMMANDS_SUCCESS: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Prune successful\", \"body\": \" \"}" http://notify_success:5000
|
||||
{% endif %}
|
||||
{% if restic_notify_failure != None %}
|
||||
POST_COMMANDS_FAILURE: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Prune failed\", \"body\": \" \"}" http://notify_failure:5000
|
||||
{% endif %}
|
||||
{% if restic_notify_exit != None %}
|
||||
POST_COMMANDS_EXIT: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Prune exited\", \"body\": \" \"}" http://notify_exit:5000
|
||||
{% endif %}
|
||||
{% if restic_repo is regex('^/.+') %}
|
||||
volumes:
|
||||
- "{{ restic_repo }}:{{ restic_repo }}"
|
||||
|
|
@ -20,6 +36,8 @@ services:
|
|||
check:
|
||||
image: "mazzolino/restic:{{ restic_version }}"
|
||||
hostname: docker
|
||||
networks:
|
||||
- restic_notify
|
||||
environment:
|
||||
- "TZ={{ restic_tz }}"
|
||||
- "SKIP_INIT=true" # only run init on one container to avoid race cond
|
||||
|
|
@ -30,7 +48,47 @@ services:
|
|||
- "RESTIC_PASSWORD={{ restic_pass }}"
|
||||
- "AWS_ACCESS_KEY_ID={{ restic_s3_key }}"
|
||||
- "AWS_SECRET_ACCESS_KEY={{ restic_s3_secret }}"
|
||||
{% if restic_notify_success != None %}
|
||||
POST_COMMANDS_SUCCESS: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Check successful\", \"body\": \" \"}" http://notify_success:5000
|
||||
{% endif %}
|
||||
{% if restic_notify_failure != None %}
|
||||
POST_COMMANDS_FAILURE: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Check failed\", \"body\": \" \"}" http://notify_failure:5000
|
||||
{% endif %}
|
||||
{% if restic_notify_exit != None %}
|
||||
POST_COMMANDS_EXIT: |-
|
||||
curl -X POST --data "{\"title\": \"Restic Check exited\", \"body\": \" \"}" http://notify_exit:5000
|
||||
{% endif %}
|
||||
{% if restic_repo is regex('^/.+') %}
|
||||
volumes:
|
||||
- "{{ restic_repo }}:{{ restic_repo }}"
|
||||
{% endif %}
|
||||
|
||||
{% if restic_notify_success != None %}
|
||||
notify_success:
|
||||
image: mazzolino/apprise-microservice:latest
|
||||
networks:
|
||||
- restic_notify
|
||||
environment:
|
||||
NOTIFICATION_URLS: {{ restic_notify_success }}
|
||||
{% endif %}
|
||||
{% if restic_notify_failure != None %}
|
||||
notify_failure:
|
||||
image: mazzolino/apprise-microservice:latest
|
||||
networks:
|
||||
- restic_notify
|
||||
environment:
|
||||
NOTIFICATION_URLS: {{ restic_notify_failure }}
|
||||
{% endif %}
|
||||
{% if restic_notify_exit != None %}
|
||||
notify_exit:
|
||||
image: mazzolino/apprise-microservice:latest
|
||||
networks:
|
||||
- restic_notify
|
||||
environment:
|
||||
NOTIFICATION_URLS: {{ restic_notify_exit }}
|
||||
{% endif %}
|
||||
|
||||
networks:
|
||||
restic_notify:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue