make schedule a paramter and configure nightly & monthly cron jobs

pull/27/head
Cian Hatton 3 years ago
parent 35afd3d71f
commit d49819acec

@ -3,12 +3,6 @@ backups:
monthly: monthly monthly: monthly
nightly: nightly 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 related config
dashy: dashy:
source_file: dashboards/dashy-config.yml source_file: dashboards/dashy-config.yml

@ -1,6 +1,11 @@
--- ---
- hosts: qnap - hosts: qnap
become: true become: true
vars:
# corrsponds to which category of backups will be used.
# determined based on the docker labels.
schedule: nightly
pre_tasks: pre_tasks:
- name: Include vault variables. - name: Include vault variables.
include_vars: '../{{vault_file}}' include_vars: '../{{vault_file}}'
@ -13,7 +18,8 @@
containers: true containers: true
containers_filters: containers_filters:
label: label:
- ie.cianhatton.backup.enabled=true - "ie.cianhatton.backup.enabled=true"
- "ie.cianhatton.backup.schedule={{ schedule }}"
register: filter_output register: filter_output
- debug: msg="{{filter_output}}" - debug: msg="{{filter_output}}"

@ -28,7 +28,6 @@
with_items: with_items:
- '{{dashy.config_directory}}' - '{{dashy.config_directory}}'
- '{{olivetin.config_directory}}' - '{{olivetin.config_directory}}'
- '{{dockervolumebackup.config_directory}}'
- '{{directories.backups_dir}}/.s3tmp' - '{{directories.backups_dir}}/.s3tmp'
- name: Dashy | Config Files - name: Dashy | Config Files
@ -45,13 +44,6 @@
notify: notify:
- restart-olivetin - 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) - name: Install python dependencies (requests)
pip: pip:
name: requests name: requests
@ -113,12 +105,21 @@
state: present state: present
with_items: '{{services}}' with_items: '{{services}}'
- name: Ensure Cron Backups - name: Ensure Nightly Cron Backups
ansible.builtin.cron: ansible.builtin.cron:
name: backup docker volumes name: backup docker volumes (nightly)
weekday: "0" weekday: "0"
minute: "0" minute: "0"
hour: "3" hour: "3"
user: ansible user: ansible
job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml" job: "ansible-pull -U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly"
cron_file: ansible_docker_volume_backup 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

@ -5,7 +5,7 @@ services:
gitea: gitea:
labels: labels:
ie.cianhatton.backup.enabled: "true" 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 image: gitea/gitea:1.16.9
container_name: gitea container_name: gitea
environment: environment:

@ -4,7 +4,7 @@ services:
linkding: linkding:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}"
container_name: "linkding" container_name: "linkding"
image: sissbruecker/linkding:latest image: sissbruecker/linkding:latest
ports: ports:

@ -4,7 +4,7 @@ services:
mariadb: mariadb:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}"
container_name: mariadb container_name: mariadb
image: mariadb image: mariadb
hostname: mariadb hostname: mariadb

@ -4,7 +4,7 @@ services:
mealie: mealie:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}"
container_name: mealie container_name: mealie
image: hkotel/mealie:latest image: hkotel/mealie:latest
restart: unless-stopped restart: unless-stopped

@ -4,7 +4,7 @@ services:
nextcloud: nextcloud:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{backups.schedule_keys.nightly}}"
image: nextcloud image: nextcloud
container_name: nextcloud container_name: nextcloud
restart: unless-stopped restart: unless-stopped

@ -4,7 +4,7 @@ services:
nginx-proxy-manager: nginx-proxy-manager:
labels: labels:
ie.cianhatton.backup.enabled: "true" 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 image: jlesage/nginx-proxy-manager
container_name: nginx-proxy-manager container_name: nginx-proxy-manager
restart: unless-stopped restart: unless-stopped

@ -4,7 +4,7 @@ services:
overseerr: overseerr:
labels: labels:
ie.cianhatton.backup.enabled: "true" 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 image: sctx/overseerr:latest
container_name: overseerr container_name: overseerr
ports: ports:

@ -4,7 +4,7 @@ services:
plex: plex:
labels: labels:
ie.cianhatton.backup.enabled: "true" 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 image: lscr.io/linuxserver/plex:latest
container_name: plex container_name: plex
ports: ports:

@ -4,7 +4,7 @@ services:
uptime-kuma: uptime-kuma:
labels: labels:
ie.cianhatton.backup.enabled: "true" 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 image: louislam/uptime-kuma:1
container_name: uptime-kuma container_name: uptime-kuma
volumes: volumes:

@ -34,7 +34,7 @@ services:
qbittorrent: qbittorrent:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}"
depends_on: depends_on:
- surfshark - surfshark
@ -54,7 +54,7 @@ services:
radarr: radarr:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}"
depends_on: depends_on:
- surfshark - surfshark
image: lscr.io/linuxserver/radarr:latest image: lscr.io/linuxserver/radarr:latest
@ -76,7 +76,7 @@ services:
image: lscr.io/linuxserver/sonarr:latest image: lscr.io/linuxserver/sonarr:latest
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}"
container_name: sonarr container_name: sonarr
network_mode: service:surfshark network_mode: service:surfshark
environment: environment:
@ -92,7 +92,7 @@ services:
jackett: jackett:
labels: labels:
ie.cianhatton.backup.enabled: "true" ie.cianhatton.backup.enabled: "true"
ie.cianhatton.backup.key: "{{backups.schedule_keys.nightly}}" ie.cianhatton.backup.schedule: "{{ backups.schedule_keys.nightly }}"
depends_on: depends_on:
- surfshark - surfshark
image: lscr.io/linuxserver/jackett:latest image: lscr.io/linuxserver/jackett:latest

@ -3,7 +3,7 @@ services:
portainer: portainer:
labels: labels:
ie.cianhatton.backup.enabled: 'true' ie.cianhatton.backup.enabled: 'true'
ie.cianhatton.backup.key: nightly ie.cianhatton.backup.schedule: nightly
image: portainer/portainer-ce image: portainer/portainer-ce
container_name: portainer container_name: portainer
ports: ports:

Loading…
Cancel
Save