diff --git a/group_vars/all.yml b/group_vars/all.yml index 4292928..942f772 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -4,8 +4,9 @@ server: domain: mrdev023.test backup: folder: /backup - cron_expression: "0 2 * * *" + cron_expression: "* * * * *" retention_days: 7 + filename_date_format: "%Y-%m-%d" acme: email: florian.richer.97@outlook.com debug: true diff --git a/roles/cloud/templates/docker-compose.yml.j2 b/roles/cloud/templates/docker-compose.yml.j2 index cb3eaa0..222e5dc 100644 --- a/roles/cloud/templates/docker-compose.yml.j2 +++ b/roles/cloud/templates/docker-compose.yml.j2 @@ -58,12 +58,13 @@ services: - POSTGRES_HOST=db - OVERWRITEPROTOCOL=https + # BACKUP backup_nextcloud: image: offen/docker-volume-backup:latest restart: always environment: BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" - BACKUP_FILENAME: "%Y-%m-%d-nextcloud.tar.gz" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-nextcloud.tar.gz" BACKUP_LATEST_SYMLINK: nextcloud.latest.tar.gz BACKUP_EXCLUDE_REGEXP: "\\.log$$" BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" @@ -76,7 +77,7 @@ services: restart: always environment: BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" - BACKUP_FILENAME: "%Y-%m-%d-db.tar.gz" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-db.tar.gz" BACKUP_LATEST_SYMLINK: db.latest.tar.gz BACKUP_EXCLUDE_REGEXP: "\\.log$$" BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" diff --git a/roles/home_assistant/templates/docker-compose.yml.j2 b/roles/home_assistant/templates/docker-compose.yml.j2 index e033599..6e96dac 100644 --- a/roles/home_assistant/templates/docker-compose.yml.j2 +++ b/roles/home_assistant/templates/docker-compose.yml.j2 @@ -22,5 +22,19 @@ services: # - "traefik.http.routers.homeassistant-secure.service=homeassistant" - "traefik.http.services.homeassistant.loadbalancer.server.port=8123" + # BACKUP + backup_home_assistant_config: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-home-assistant-config.tar.gz" + BACKUP_LATEST_SYMLINK: home-assistant-config.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - home_assistant_config:/backup:ro + - {{ server.backup.folder }}/home_assistant:/archive + volumes: home_assistant_config: \ No newline at end of file diff --git a/roles/matrix/templates/docker-compose.yml.j2 b/roles/matrix/templates/docker-compose.yml.j2 index 1e6e2e7..d996328 100644 --- a/roles/matrix/templates/docker-compose.yml.j2 +++ b/roles/matrix/templates/docker-compose.yml.j2 @@ -24,6 +24,9 @@ services: - proxy volumes: - matrix:/data + - mautrix_facebook:/facebook_data + - mautrix_instagram:/instagram_data + - mautrix_discord:/discord_data labels: - "traefik.enable=true" - "traefik.http.routers.matrix-secure.entrypoints=https" @@ -52,12 +55,107 @@ services: - "traefik.http.routers.matrix-wellknown.tls.certresolver=sslResolver" - "traefik.http.routers.matrix-wellknown.middlewares=cors-headers@docker" - "traefik.docker.network=proxy" + + # BRIDGE + mautrix-facebook: + container_name: mautrix-facebook + image: dock.mau.dev/mautrix/facebook:v0.4.1 + restart: unless-stopped + networks: + - internal + volumes: + - mautrix_facebook:/data + mautrix-instagram: + container_name: mautrix-instagram + image: dock.mau.dev/mautrix/instagram:v0.2.3 + restart: unless-stopped + networks: + - internal + volumes: + - mautrix_instagram:/data + + mautrix-discord: + container_name: mautrix-discord + image: dock.mau.dev/mautrix/discord:v0.2.0 + restart: unless-stopped + networks: + - internal + volumes: + - mautrix_discord:/data + + # BACKUP + backup_db: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-db.tar.gz" + BACKUP_LATEST_SYMLINK: db.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - db:/backup:ro + - {{ server.backup.folder }}/matrix:/archive + + backup_matrix: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-matrix.tar.gz" + BACKUP_LATEST_SYMLINK: matrix.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - matrix:/backup:ro + - {{ server.backup.folder }}/matrix:/archive + + backup_mautrix_facebook: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-mautrix-facebook.tar.gz" + BACKUP_LATEST_SYMLINK: mautrix-facebook.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - mautrix_facebook:/backup:ro + - {{ server.backup.folder }}/matrix:/archive + + backup_mautrix_instagram: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-mautrix-instagram.tar.gz" + BACKUP_LATEST_SYMLINK: mautrix-instagram.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - mautrix_instagram:/backup:ro + - {{ server.backup.folder }}/matrix:/archive + + backup_mautrix_discord: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-mautrix-discord.tar.gz" + BACKUP_LATEST_SYMLINK: mautrix-discord.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - mautrix_discord:/backup:ro + - {{ server.backup.folder }}/matrix:/archive volumes: db: - web: matrix: + mautrix_facebook: + mautrix_instagram: + mautrix_discord: networks: internal: diff --git a/roles/n8n/templates/docker-compose.yml.j2 b/roles/n8n/templates/docker-compose.yml.j2 index 2d35442..e222e38 100644 --- a/roles/n8n/templates/docker-compose.yml.j2 +++ b/roles/n8n/templates/docker-compose.yml.j2 @@ -40,6 +40,33 @@ services: - DB_POSTGRESDB_USER=n8n - DB_POSTGRESDB_PASSWORD=n8n + # BACKUP + backup_n8n: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-n8n.tar.gz" + BACKUP_LATEST_SYMLINK: n8n.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - n8n:/backup:ro + - {{ server.backup.folder }}/n8n:/archive + + backup_db: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-db.tar.gz" + BACKUP_LATEST_SYMLINK: db.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - db:/backup:ro + - {{ server.backup.folder }}/n8n:/archive + volumes: n8n: db: diff --git a/roles/protonmail/files/docker-compose.yml b/roles/protonmail/files/docker-compose.yml deleted file mode 100644 index f5a7501..0000000 --- a/roles/protonmail/files/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3' - -services: - protonmail-bridge: - image: shenxn/protonmail-bridge - restart: always - container_name: protonmail-bridge - networks: - - protonmail - volumes: - - protonmail:/root - -volumes: - protonmail: - -networks: - protonmail: - external: true diff --git a/roles/protonmail/tasks/base.yml b/roles/protonmail/tasks/base.yml index 148b379..4b8fb09 100644 --- a/roles/protonmail/tasks/base.yml +++ b/roles/protonmail/tasks/base.yml @@ -12,6 +12,15 @@ dest: protonmail/ register: protonmail_copy_files_results +- name: Copy template conf + ansible.builtin.template: + backup: true + src: "{{ item.src }}" + dest: "protonmail/{{ item.dest }}" + loop: + - { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' } + register: protonmail_copy_templates_results + - name: Create protonmail network community.docker.docker_network: name: protonmail @@ -29,7 +38,7 @@ state: present pull: true restarted: true - when: protonmail.initialized and protonmail_copy_files_results.changed + when: protonmail.initialized and (protonmail_copy_templates_results.changed or protonmail_copy_files_results.changed) become: true - name: Update or start container @@ -37,5 +46,5 @@ project_src: protonmail state: present pull: true - when: protonmail.initialized and not protonmail_copy_files_results.changed + when: protonmail.initialized and not protonmail_copy_templates_results.changed and not protonmail_copy_files_results.changed become: true \ No newline at end of file diff --git a/roles/protonmail/templates/docker-compose.yml.j2 b/roles/protonmail/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..5b9c271 --- /dev/null +++ b/roles/protonmail/templates/docker-compose.yml.j2 @@ -0,0 +1,31 @@ +version: '3' + +services: + protonmail-bridge: + image: shenxn/protonmail-bridge + restart: always + container_name: protonmail-bridge + networks: + - protonmail + volumes: + - protonmail:/root + + backup_protonmail: + image: offen/docker-volume-backup:latest + restart: always + environment: + BACKUP_CRON_EXPRESSION: "{{ server.backup.cron_expression }}" + BACKUP_FILENAME: "{{ server.backup.filename_date_format }}-protonmail.tar.gz" + BACKUP_LATEST_SYMLINK: protonmail.latest.tar.gz + BACKUP_EXCLUDE_REGEXP: "\\.log$$" + BACKUP_RETENTION_DAYS: "{{ server.backup.retention_days }}" + volumes: + - protonmail:/backup:ro + - {{ server.backup.folder }}/protonmail:/archive + +volumes: + protonmail: + +networks: + protonmail: + external: true