From 5ee5bbfcb572fcb44e2cbccbf7d8ddc962f4d0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Mon, 1 May 2023 09:12:29 +0200 Subject: [PATCH 1/4] Add backup borg --- group_vars/mash_servers | 47 +++++++++++++++++++++++++++++++++++++++++ requirements.yml | 2 ++ setup.yml | 2 ++ 3 files changed, 51 insertions(+) diff --git a/group_vars/mash_servers b/group_vars/mash_servers index 1d52077..0eb68c7 100644 --- a/group_vars/mash_servers +++ b/group_vars/mash_servers @@ -594,6 +594,53 @@ authentik_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certRes +######################################################################## +# # +# backup-borg # +# # +######################################################################## + +backup_borg_enabled: false + +backup_borg_identifier: "{{ mash_playbook_service_identifier_prefix }}backup-borg" + +backup_borg_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}borg-backup" + +backup_borg_uid: "{{ mash_playbook_uid }}" +backup_borg_gid: "{{ mash_playbook_gid }}" + +backup_borg_container_network: "{{ devture_postgres_container_network if devture_postgres_enabled else backup_borg_identifier }}" + +backup_borg_retention_prefix: "{{ mash_playbook_service_identifier_prefix }}" +backup_borg_storage_archive_name_format: "{{ mash_playbook_service_identifier_prefix }}-{now:%Y-%m-%d-%H%M%S}" + +backup_borg_container_image_self_build: "{{ mash_playbook_architecture not in ['amd64', 'arm32', 'arm64'] }}" + +backup_borg_postgresql_enabled: "{{ devture_postgres_enabled }}" +backup_borg_postgresql_databases_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}" +backup_borg_postgresql_databases_username: "{{ devture_postgres_connection_username if devture_postgres_enabled else '' }}" +backup_borg_postgresql_databases_password: "{{ devture_postgres_connection_password if devture_postgres_enabled else '' }}" +backup_borg_postgresql_databases_port: "{{ devture_postgres_connection_port if devture_postgres_enabled else 5432 }}" +backup_borg_postgresql_databases: "{{ devture_postgres_managed_databases | map(attribute='name') if devture_postgres_enabled else [] }}" + +backup_borg_location_source_directories: + - "{{ mash_playbook_base_path }}" + +backup_borg_systemd_required_services_list: | + {{ + ['docker.service'] + + + ([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled else []) + }} + +######################################################################## +# # +# /backup-borg # +# # +######################################################################## + + + ######################################################################## # # # collabora-online # diff --git a/requirements.yml b/requirements.yml index 1925114..3b0279e 100644 --- a/requirements.yml +++ b/requirements.yml @@ -12,6 +12,8 @@ - src: git+https://github.com/mother-of-all-self-hosting/ansible-role-aux.git version: v1.0.0-0 name: aux +- src: git+https://gitlab.com/etke.cc/roles/backup_borg.git + version: v1.2.4-1.7.12-1 - src: git+https://github.com/mother-of-all-self-hosting/ansible-role-collabora-online.git version: v22.05.13.1.1-0 name: collabora_online diff --git a/setup.yml b/setup.yml index 6a82a71..2786272 100644 --- a/setup.yml +++ b/setup.yml @@ -60,6 +60,8 @@ - role: galaxy/authentik + - role: galaxy/backup_borg + - role: galaxy/collabora_online - role: galaxy/docker_registry From 132159ca0fe62162a3784d943cae8c12c4b1e9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Mon, 1 May 2023 17:43:52 +0200 Subject: [PATCH 2/4] Add mysql support + add exclude patterns --- group_vars/mash_servers | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/group_vars/mash_servers b/group_vars/mash_servers index 0eb68c7..f92ba0a 100644 --- a/group_vars/mash_servers +++ b/group_vars/mash_servers @@ -623,14 +623,29 @@ backup_borg_postgresql_databases_password: "{{ devture_postgres_connection_passw backup_borg_postgresql_databases_port: "{{ devture_postgres_connection_port if devture_postgres_enabled else 5432 }}" backup_borg_postgresql_databases: "{{ devture_postgres_managed_databases | map(attribute='name') if devture_postgres_enabled else [] }}" +backup_borg_mysql_enabled: "{{ mariadb_enabled }}" +backup_borg_mysql_databases_hostname: "{{ mariadb_identifier if mariadb_enabled else '' }}" +backup_borg_mysql_databases_username: "root" +backup_borg_mysql_databases_password: "{{ mariadb_root_passsword if mariadb_enabled else '' }}" +backup_borg_mysql_databases_port: "{{ devture_postgres_connection_port if mariadb_enabled else 3306 }}" +backup_borg_mysql_databases: "{{ mariadb_managed_databases | map(attribute='name') if mariadb_enabled else [] }}" + + backup_borg_location_source_directories: - "{{ mash_playbook_base_path }}" +backup_borg_location_exclude_patterns: + - "{{ devture_postgres_data_path if devture_postgres_enabled else '' }}" + - "{{ mariadb_data_path if mariadb_enabled else '' }}" + + backup_borg_systemd_required_services_list: | {{ ['docker.service'] + ([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled else []) + + + ([mariadb_identifier ~ '.service'] if mariadb_enabled else []) }} ######################################################################## From ab05b6df3ff0e3e4b1ffa74529737d927bbb730d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Tue, 2 May 2023 07:58:06 +0200 Subject: [PATCH 3/4] Bump Backup-Borg version --- requirements.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.yml b/requirements.yml index 3b0279e..70b1b2b 100644 --- a/requirements.yml +++ b/requirements.yml @@ -13,7 +13,7 @@ version: v1.0.0-0 name: aux - src: git+https://gitlab.com/etke.cc/roles/backup_borg.git - version: v1.2.4-1.7.12-1 + version: v1.2.4-1.7.12-2 - src: git+https://github.com/mother-of-all-self-hosting/ansible-role-collabora-online.git version: v22.05.13.1.1-0 name: collabora_online From c645f2ae8e75c416d710d26bc4a558dd94ddd41d Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 2 May 2023 09:16:53 +0300 Subject: [PATCH 4/4] Redo backup_borg_location_exclude_patterns to ensure it doesn't contain empty strings Previously, if Postgres or MariaDB were disabled, an empty path (`''`) would be injected. I'm not sure how borg-backup would handle such paths, but I suppose we'd better not feed it such stuff. --- group_vars/mash_servers | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/group_vars/mash_servers b/group_vars/mash_servers index f92ba0a..3cb824c 100644 --- a/group_vars/mash_servers +++ b/group_vars/mash_servers @@ -630,14 +630,15 @@ backup_borg_mysql_databases_password: "{{ mariadb_root_passsword if mariadb_enab backup_borg_mysql_databases_port: "{{ devture_postgres_connection_port if mariadb_enabled else 3306 }}" backup_borg_mysql_databases: "{{ mariadb_managed_databases | map(attribute='name') if mariadb_enabled else [] }}" - backup_borg_location_source_directories: - "{{ mash_playbook_base_path }}" -backup_borg_location_exclude_patterns: - - "{{ devture_postgres_data_path if devture_postgres_enabled else '' }}" - - "{{ mariadb_data_path if mariadb_enabled else '' }}" - +backup_borg_location_exclude_patterns: | + {{ + ([devture_postgres_data_path] if devture_postgres_enabled else []) + + + ([mariadb_data_path] if mariadb_enabled else []) + }} backup_borg_systemd_required_services_list: | {{