diff --git a/group_vars/servers.yml b/group_vars/servers.yml index dc1b676..4904486 100644 --- a/group_vars/servers.yml +++ b/group_vars/servers.yml @@ -3,12 +3,6 @@ backups: monthly: monthly nightly: nightly -# TODO: docker_volume_backup exists in vault. Clean this up. -#dockervolumebackup: -# image: ghcr.io/chatton/docker-volume-backup -# tag: pr-20 -# config_directory: /etc/docker-volume-backup - # dashy related config dashy: source_file: dashboards/dashy-config.yml diff --git a/playbooks/backup-docker-volumes.yml b/playbooks/backup-docker-volumes.yml index 48f6ef1..b577e5c 100644 --- a/playbooks/backup-docker-volumes.yml +++ b/playbooks/backup-docker-volumes.yml @@ -1,6 +1,11 @@ --- - hosts: qnap become: true + vars: + # corrsponds to which category of backups will be used. + # determined based on the docker labels. + schedule: nightly + pre_tasks: - name: Include vault variables. include_vars: '../{{vault_file}}' @@ -13,7 +18,8 @@ containers: true containers_filters: label: - - ie.cianhatton.backup.enabled=true + - "ie.cianhatton.backup.enabled=true" + - "ie.cianhatton.backup.schedule={{ schedule }}" register: filter_output - debug: msg="{{filter_output}}" diff --git a/roles/setup_hosted_services/tasks/main.yml b/roles/setup_hosted_services/tasks/main.yml index a24ff5b..f12bf68 100644 --- a/roles/setup_hosted_services/tasks/main.yml +++ b/roles/setup_hosted_services/tasks/main.yml @@ -28,7 +28,6 @@ with_items: - '{{dashy.config_directory}}' - '{{olivetin.config_directory}}' - - '{{dockervolumebackup.config_directory}}' - '{{directories.backups_dir}}/.s3tmp' - name: Dashy | Config Files @@ -45,13 +44,6 @@ notify: - restart-olivetin -- name: Docker Volume Backup | Config Files - template: - src: docker-volume-backup/config.j2 - dest: '{{dockervolumebackup.config_directory}}/config.yml' - notify: - - restart-docker-volume-backup - - name: Install python dependencies (requests) pip: name: requests @@ -113,12 +105,21 @@ state: present with_items: '{{services}}' -- name: Ensure Cron Backups +- name: Ensure Nightly Cron Backups ansible.builtin.cron: - name: backup docker volumes + name: backup docker volumes (nightly) weekday: "0" minute: "0" hour: "3" user: ansible - job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml" - cron_file: ansible_docker_volume_backup + job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly" + cron_file: ansible_nightly_docker_volume_backup + +- name: Ensure Monthly Cron Backups + ansible.builtin.cron: + name: backup docker volumes (monthly) + month: "*" + day : "1" + user: ansible + job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly" + cron_file: ansible_monthly_docker_volume_backup diff --git a/roles/setup_hosted_services/templates/gitea.j2 b/roles/setup_hosted_services/templates/gitea.j2 index b56a98c..be74e08 100644 --- a/roles/setup_hosted_services/templates/gitea.j2 +++ b/roles/setup_hosted_services/templates/gitea.j2 @@ -5,7 +5,7 @@ services: gitea: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.monthly}}" image: gitea/gitea:1.16.9 container_name: gitea environment: diff --git a/roles/setup_hosted_services/templates/linkding.j2 b/roles/setup_hosted_services/templates/linkding.j2 index bda2c92..97f8e0a 100644 --- a/roles/setup_hosted_services/templates/linkding.j2 +++ b/roles/setup_hosted_services/templates/linkding.j2 @@ -4,7 +4,7 @@ services: linkding: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" container_name: "linkding" image: sissbruecker/linkding:latest ports: diff --git a/roles/setup_hosted_services/templates/mariadb.j2 b/roles/setup_hosted_services/templates/mariadb.j2 index 9f60fa4..32c0e7e 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.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" container_name: mariadb image: mariadb hostname: mariadb diff --git a/roles/setup_hosted_services/templates/mealie.j2 b/roles/setup_hosted_services/templates/mealie.j2 index 64a52cb..dc6c4f4 100644 --- a/roles/setup_hosted_services/templates/mealie.j2 +++ b/roles/setup_hosted_services/templates/mealie.j2 @@ -4,7 +4,7 @@ services: mealie: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" container_name: mealie image: hkotel/mealie:latest restart: unless-stopped diff --git a/roles/setup_hosted_services/templates/nextcloud.j2 b/roles/setup_hosted_services/templates/nextcloud.j2 index af97104..af9499d 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.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" image: nextcloud container_name: nextcloud restart: unless-stopped diff --git a/roles/setup_hosted_services/templates/nginx-proxy-manager.j2 b/roles/setup_hosted_services/templates/nginx-proxy-manager.j2 index 5bdfc3a..681f23c 100644 --- a/roles/setup_hosted_services/templates/nginx-proxy-manager.j2 +++ b/roles/setup_hosted_services/templates/nginx-proxy-manager.j2 @@ -4,7 +4,7 @@ services: nginx-proxy-manager: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" image: jlesage/nginx-proxy-manager container_name: nginx-proxy-manager restart: unless-stopped diff --git a/roles/setup_hosted_services/templates/overseerr.j2 b/roles/setup_hosted_services/templates/overseerr.j2 index 768d10f..c5ab5d3 100644 --- a/roles/setup_hosted_services/templates/overseerr.j2 +++ b/roles/setup_hosted_services/templates/overseerr.j2 @@ -4,7 +4,7 @@ services: overseerr: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" image: sctx/overseerr:latest container_name: overseerr ports: diff --git a/roles/setup_hosted_services/templates/plex.j2 b/roles/setup_hosted_services/templates/plex.j2 index 61f790c..da12e96 100644 --- a/roles/setup_hosted_services/templates/plex.j2 +++ b/roles/setup_hosted_services/templates/plex.j2 @@ -4,7 +4,7 @@ services: plex: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.monthly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.monthly}}" image: lscr.io/linuxserver/plex:latest container_name: plex ports: diff --git a/roles/setup_hosted_services/templates/uptime-kuma.j2 b/roles/setup_hosted_services/templates/uptime-kuma.j2 index c1cc3e9..5ebcb76 100644 --- a/roles/setup_hosted_services/templates/uptime-kuma.j2 +++ b/roles/setup_hosted_services/templates/uptime-kuma.j2 @@ -4,7 +4,7 @@ services: uptime-kuma: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}" image: louislam/uptime-kuma:1 container_name: uptime-kuma volumes: diff --git a/roles/setup_hosted_services/templates/vpn-stack.j2 b/roles/setup_hosted_services/templates/vpn-stack.j2 index 7f3c74b..411abac 100644 --- a/roles/setup_hosted_services/templates/vpn-stack.j2 +++ b/roles/setup_hosted_services/templates/vpn-stack.j2 @@ -34,7 +34,7 @@ services: qbittorrent: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" depends_on: - surfshark @@ -54,7 +54,7 @@ services: radarr: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" depends_on: - surfshark image: lscr.io/linuxserver/radarr:latest @@ -76,7 +76,7 @@ services: image: lscr.io/linuxserver/sonarr:latest labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" container_name: sonarr network_mode: service:surfshark environment: @@ -92,7 +92,7 @@ services: jackett: labels: ie.cianhatton.backup.enabled: "true" - ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" + ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}" depends_on: - surfshark image: lscr.io/linuxserver/jackett:latest diff --git a/roles/setup_portainer/files/docker-compose.yml b/roles/setup_portainer/files/docker-compose.yml index e6ae5b7..4755e29 100644 --- a/roles/setup_portainer/files/docker-compose.yml +++ b/roles/setup_portainer/files/docker-compose.yml @@ -3,7 +3,7 @@ services: portainer: labels: ie.cianhatton.backup.enabled: 'true' - ie.cianhatton.backup.key: nightly + ie.cianhatton.backup.schedule: nightly image: portainer/portainer-ce container_name: portainer ports: