From bdcdf3c87b770a30023bdf872bc2588789125277 Mon Sep 17 00:00:00 2001 From: chatton Date: Thu, 28 Sep 2023 16:41:43 +0100 Subject: [PATCH] use weekly and monthly backups instead of daily --- group_vars/servers.yml | 3 +- playbooks/backup-docker-volumes.yml | 2 +- roles/portainer_plex/tasks/main.yml | 7 ++++- roles/setup_hosted_services/tasks/main.yml | 29 +++++++++++++++++++ .../setup_hosted_services/templates/ghost.j2 | 2 +- .../templates/hasteypaste.j2 | 2 +- .../templates/mariadb.j2 | 2 +- .../templates/nextcloud.j2 | 2 +- .../templates/paperless.j2 | 2 +- 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/group_vars/servers.yml b/group_vars/servers.yml index c9ac651..52366e9 100644 --- a/group_vars/servers.yml +++ b/group_vars/servers.yml @@ -2,6 +2,7 @@ backups: schedule_keys: monthly: monthly nightly: nightly + weekly: weekly homelab_user: &main_user cianhatton @@ -21,7 +22,7 @@ portainer_required_files: [] restart_policy: unless-stopped backup_labels: ie.cianhatton.backup.enabled: true - ie.cianhatton.backup.schedule: nightly + ie.cianhatton.backup.schedule: weekly docker_backup_aws_s3_encrypt: true docker_backup_host_backup_directory: "/tmp" diff --git a/playbooks/backup-docker-volumes.yml b/playbooks/backup-docker-volumes.yml index 6c4c707..1fa0efd 100644 --- a/playbooks/backup-docker-volumes.yml +++ b/playbooks/backup-docker-volumes.yml @@ -5,7 +5,7 @@ vars: # corrsponds to which category of backups will be used. # determined based on the docker labels. - schedule: nightly + schedule: weekly pre_tasks: - name: Include vault variables. diff --git a/roles/portainer_plex/tasks/main.yml b/roles/portainer_plex/tasks/main.yml index 78a5a92..fcf7246 100644 --- a/roles/portainer_plex/tasks/main.yml +++ b/roles/portainer_plex/tasks/main.yml @@ -8,6 +8,11 @@ - name: "{{ plex_portainer_stack_name }}_config" - name: "{{ plex_portainer_stack_name }}_tautulli_config" +- name: Plex | Set fact plex_labels. + set_fact: + plex_labels: + ie.cianhatton.backup.schedule: monthly + - name: "Plex | Update Portainer." chatton.portainer.portainer_stack: username: '{{ portainer_user }}' @@ -20,7 +25,7 @@ version: "3" services: plex: - labels: "{{ backup_labels }}" + labels: "{{ backup_labels | combine(plex_labels) }}" image: "{{ plex_image }}:{{ plex_tag }}" container_name: "{{ plex_container_name }}" ports: diff --git a/roles/setup_hosted_services/tasks/main.yml b/roles/setup_hosted_services/tasks/main.yml index 3d2b23b..2c14b44 100644 --- a/roles/setup_hosted_services/tasks/main.yml +++ b/roles/setup_hosted_services/tasks/main.yml @@ -62,4 +62,33 @@ {{ ansible_pull_path }} -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> ~/logs/nightly.log 2>&1 cron_file: ansible_nightly_docker_volume_backup + state: absent + +- name: Ensure Weekly Cron Backups + tags: ["cron"] + ansible.builtin.cron: + name: backup docker volumes (weekly) + weekday: "0" + minute: "0" + hour: "{{ cron_hour }}" + user: "{{ homelab_user }}" + job: > + {{ ansible_pull_path }} + -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=weekly >> ~/logs/weekly.log 2>&1 + cron_file: ansible_weekly_docker_volume_backup + state: present + + +- name: Ensure Monthly Cron Backups + tags: ["cron"] + ansible.builtin.cron: + name: backup docker volumes (monthly) + day: "1" + minute: "0" + hour: "{{ cron_hour }}" + user: "{{ homelab_user }}" + job: > + {{ ansible_pull_path }} + -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> ~/logs/monthly.log 2>&1 + cron_file: ansible_monthly_docker_volume_backup state: present diff --git a/roles/setup_hosted_services/templates/ghost.j2 b/roles/setup_hosted_services/templates/ghost.j2 index 3ddf8cf..4db51f4 100644 --- a/roles/setup_hosted_services/templates/ghost.j2 +++ b/roles/setup_hosted_services/templates/ghost.j2 @@ -4,7 +4,7 @@ services: ghost: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.weekly }}" image: ghost:4-alpine restart: unless-stopped container_name: ghost diff --git a/roles/setup_hosted_services/templates/hasteypaste.j2 b/roles/setup_hosted_services/templates/hasteypaste.j2 index c919f31..8a09995 100644 --- a/roles/setup_hosted_services/templates/hasteypaste.j2 +++ b/roles/setup_hosted_services/templates/hasteypaste.j2 @@ -4,7 +4,7 @@ services: hastey-paste: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.weekly }}" container_name: hastey-paste image: ghcr.io/enchant97/hasty-paste:1 restart: unless-stopped diff --git a/roles/setup_hosted_services/templates/mariadb.j2 b/roles/setup_hosted_services/templates/mariadb.j2 index 4f06a3b..ce2226e 100644 --- a/roles/setup_hosted_services/templates/mariadb.j2 +++ b/roles/setup_hosted_services/templates/mariadb.j2 @@ -4,7 +4,7 @@ services: mariadb: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.weekly }}" container_name: mariadb image: "{{ template_vars.image }}:{{ template_vars.tag }}" hostname: mariadb diff --git a/roles/setup_hosted_services/templates/nextcloud.j2 b/roles/setup_hosted_services/templates/nextcloud.j2 index 9fa89db..0b81d05 100644 --- a/roles/setup_hosted_services/templates/nextcloud.j2 +++ b/roles/setup_hosted_services/templates/nextcloud.j2 @@ -4,7 +4,7 @@ services: nextcloud: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.weekly }}" image: "{{ template_vars.image }}:{{ template_vars.tag }}" container_name: nextcloud restart: unless-stopped diff --git a/roles/setup_hosted_services/templates/paperless.j2 b/roles/setup_hosted_services/templates/paperless.j2 index 17bfd07..67c1790 100644 --- a/roles/setup_hosted_services/templates/paperless.j2 +++ b/roles/setup_hosted_services/templates/paperless.j2 @@ -4,7 +4,7 @@ services: paperless-ng: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.weekly }}" image: lscr.io/linuxserver/paperless-ng:latest container_name: paperless-ng environment: