From 9ae295896f9b13ea86aca71394cd26e3cd54e864 Mon Sep 17 00:00:00 2001 From: Jesper Hess Nielsen Date: Tue, 26 Jan 2021 20:40:22 +0100 Subject: [PATCH] Use docker_service ansible command --- roles/docker/tasks/services/restic-backup.yml | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/roles/docker/tasks/services/restic-backup.yml b/roles/docker/tasks/services/restic-backup.yml index a7ae7115..b8c4c133 100644 --- a/roles/docker/tasks/services/restic-backup.yml +++ b/roles/docker/tasks/services/restic-backup.yml @@ -1,32 +1,37 @@ --- - -- name: restic network - docker_network: - name: restic - -- name: restic container - docker_container: - name: restic-backup - image: mazzolino/restic - state: started - restart_policy: always - networks: - - name: restic - env: - RUN_ON_STARTUP: "true" - BACKUP_CRON: "0 30 3 * * *" - RESTIC_REPOSITORY: "rest:https://datacoop:{{ restic_secrets.user_secret }}@restic.graffen.io/datacoop-hevonen" - RESTIC_PASSWORD: "{{ restic_secrets.encryption_secret }}" - RESTIC_BACKUP_SOURCES: "/mnt/volumes" - RESTIC_BACKUP_ARGS: >- - --tag datacoop-volumes - --exclude='*.tmp' - --verbose - RESTIC_FORGET_ARGS: >- - --keep-last 10 - --keep-daily 7 - --keep-weekly 5 - --keep-monthly 12 - TZ: Europe/Copenhagen - volumes: - - /docker-volumes:/mnt/volumes:ro +- docker_service: + project_name: restic_backup + pull: yes + definition: + version: '3.6' + services: + restic-backup: + image: mazzolino/restic + restart: always + environment: + RUN_ON_STARTUP: "true" + BACKUP_CRON: "0 30 3 * * *" + RESTIC_REPOSITORY: "rest:https://datacoop:{{ restic_secrets.user_secret }}@restic.graffen.io/datacoop-hevonen" + RESTIC_PASSWORD: "{{ restic_secrets.encryption_secret }}" + RESTIC_BACKUP_SOURCES: "/mnt/volumes" + RESTIC_BACKUP_ARGS: >- + --tag datacoop-volumes + --exclude='*.tmp' + --verbose + RESTIC_FORGET_ARGS: >- + --keep-last 10 + --keep-daily 7 + --keep-weekly 5 + --keep-monthly 12 + TZ: Europe/Copenhagen + volumes: + - /docker-volumes:/mnt/volumes:ro + + restic-prune: + image: "mazzolino/restic" + environment: + RUN_ON_STARTUP: "true" + PRUNE_CRON: "0 0 4 * * *" + RESTIC_REPOSITORY: "rest:https://datacoop:{{ restic_secrets.user_secret }}@restic.graffen.io/datacoop-hevonen" + RESTIC_PASSWORD: "{{ restic_secrets.encryption_secret }}" + TZ: Europe/copenhagen