Add hostname to restic containers

Will pass through the hostname to any snapshots set up.
The hostname is _not_ derived from the random docker container string
but instead takes the name of the _host_ on which docker is running
(from ansible facts).

The hostname in combination with the tag should point to the correct
host -> stack which is being backed up.
This commit is contained in:
Marty Oehme 2025-07-18 18:36:19 +02:00
parent b81328d400
commit cd842ea4b5
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 8 additions and 8 deletions

View file

@ -68,6 +68,7 @@ services:
{% if restic_enable is not undefined and not false and stack_paperless_restic_enable is not undefined and not false %} {% if restic_enable is not undefined and not false and stack_paperless_restic_enable is not undefined and not false %}
backup: backup:
image: mazzolino/restic image: mazzolino/restic
hostname: "{{ ansible_hostname }}"
environment: environment:
TZ: "{{ restic_tz }}" TZ: "{{ restic_tz }}"
BACKUP_CRON: "{{ stack_paperless_restic_cron }}" BACKUP_CRON: "{{ stack_paperless_restic_cron }}"

View file

@ -1,8 +1,7 @@
services: services:
prune: prune:
image: "mazzolino/restic:{{ restic_version }}" image: "mazzolino/restic:{{ restic_version }}"
# TODO: get actual hostname/inventoryname? put it into notifications body below too hostname: "{{ ansible_hostname }}"
hostname: docker
networks: networks:
- restic_notify - restic_notify
environment: environment:
@ -17,15 +16,15 @@ services:
AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}" AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}"
{% if restic_notify_success != None %} {% if restic_notify_success != None %}
POST_COMMANDS_SUCCESS: |- POST_COMMANDS_SUCCESS: |-
curl -X POST --data "{\"title\": \"Restic Prune successful\", \"body\": \" \"}" http://notify_success:5000 curl -X POST --data "{\"title\": \"Restic Prune successful\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_success:5000
{% endif %} {% endif %}
{% if restic_notify_failure != None %} {% if restic_notify_failure != None %}
POST_COMMANDS_FAILURE: |- POST_COMMANDS_FAILURE: |-
curl -X POST --data "{\"title\": \"Restic Prune failed\", \"body\": \" \"}" http://notify_failure:5000 curl -X POST --data "{\"title\": \"Restic Prune failed\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_failure:5000
{% endif %} {% endif %}
{% if restic_notify_exit != None %} {% if restic_notify_exit != None %}
POST_COMMANDS_EXIT: |- POST_COMMANDS_EXIT: |-
curl -X POST --data "{\"title\": \"Restic Prune exited\", \"body\": \" \"}" http://notify_exit:5000 curl -X POST --data "{\"title\": \"Restic Prune exited\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_exit:5000
{% endif %} {% endif %}
{% if restic_repo is regex('^/.+') %} {% if restic_repo is regex('^/.+') %}
volumes: volumes:
@ -49,15 +48,15 @@ services:
AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}" AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}"
{% if restic_notify_success != None %} {% if restic_notify_success != None %}
POST_COMMANDS_SUCCESS: |- POST_COMMANDS_SUCCESS: |-
curl -X POST --data "{\"title\": \"Restic Check successful\", \"body\": \" \"}" http://notify_success:5000 curl -X POST --data "{\"title\": \"Restic Check successful\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_success:5000
{% endif %} {% endif %}
{% if restic_notify_failure != None %} {% if restic_notify_failure != None %}
POST_COMMANDS_FAILURE: |- POST_COMMANDS_FAILURE: |-
curl -X POST --data "{\"title\": \"Restic Check failed\", \"body\": \" \"}" http://notify_failure:5000 curl -X POST --data "{\"title\": \"Restic Check failed\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_failure:5000
{% endif %} {% endif %}
{% if restic_notify_exit != None %} {% if restic_notify_exit != None %}
POST_COMMANDS_EXIT: |- POST_COMMANDS_EXIT: |-
curl -X POST --data "{\"title\": \"Restic Check exited\", \"body\": \" \"}" http://notify_exit:5000 curl -X POST --data "{\"title\": \"Restic Check exited\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_exit:5000
{% endif %} {% endif %}
{% if restic_repo is regex('^/.+') %} {% if restic_repo is regex('^/.+') %}
volumes: volumes: