Skip to content

Commit

Permalink
fix borg postgres version check
Browse files Browse the repository at this point in the history
  • Loading branch information
aine-etke committed Nov 1, 2024
1 parent 2d59d05 commit f3f1df2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
10 changes: 5 additions & 5 deletions roles/galaxy/backup_borg/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ backup_borg_version: "{{ (backup_borg_postgres_version ~ '-' ~ backup_borg_borg_
backup_borg_postgres_version: ""
backup_borg_borg_version: 1.2.8
backup_borg_borgmatic_version: 1.8.13
backup_borg_docker_image: "{{ backup_borg_docker_image_name_prefix }}etke.cc/borgmatic:{{ backup_borg_version }}"
backup_borg_docker_image_name_prefix: "{{ 'localhost/' if backup_borg_container_image_self_build else 'registry.gitlab.com/' }}"
backup_borg_docker_image: "{{ backup_borg_docker_image_name_prefix }}etkecc/borgmatic:{{ backup_borg_version }}"
backup_borg_docker_image_name_prefix: "{{ 'localhost/' if backup_borg_container_image_self_build else 'ghcr.io/' }}"
backup_borg_docker_image_force_pull: "{{ backup_borg_docker_image.endswith(':latest') }}"

# container tmp directory size
Expand Down Expand Up @@ -60,10 +60,10 @@ backup_borg_postgresql_databases_hostname: ''
backup_borg_postgresql_databases_username: "{{ backup_borg_identifier }}"
backup_borg_postgresql_databases_password: ""
backup_borg_postgresql_databases_port: 5432
backup_borg_postgresql_version_detection_enabled: "{{ backup_borg_postgresql_version_detection_devture_postgres_role_name != '' }}"
# backup_borg_postgresql_version_detection_devture_postgres_role_name lets you control the role name, leading to the com.devture.ansible.role.postgres.
backup_borg_postgresql_version_detection_enabled: "{{ backup_borg_postgresql_version_detection_postgres_role_name != '' }}"
# backup_borg_postgresql_version_detection_postgres_role_name lets you control the role name, leading to the com.devture.ansible.role.postgres.
# This role is invoked to determine the Postgres version, unless you have set `backup_borg_version` manually.
backup_borg_postgresql_version_detection_devture_postgres_role_name: ''
backup_borg_postgresql_version_detection_postgres_role_name: ''

backup_borg_mysql_enabled: true
backup_borg_mysql_databases: []
Expand Down
6 changes: 3 additions & 3 deletions roles/galaxy/backup_borg/meta/.galaxy_install_info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
install_date: 'Mon 07 Oct 2024 02:00:09 PM '
install_commit: d54ccb7cf11f6612a220bf2081ec3c051c2e046f
version: v1.2.8-1.8.13-0
install_date: 'Fri 01 Nov 2024 05:10:49 PM '
install_commit: 1db81bb43c86d1408e3e0c2631e813e7057e5559
version: v1.2.8-1.8.13-2
23 changes: 13 additions & 10 deletions roles/galaxy/backup_borg/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@

- when: backup_borg_postgresql_enabled | bool and backup_borg_postgresql_version_detection_enabled | bool and backup_borg_postgres_version == ''
block:
- name: Fail with devture_postgres_enabled is undefined
- name: Fail with postgres_enabled is undefined
ansible.builtin.fail:
msg: >-
You have not set `backup_borg_postgres_version`, which means we'll attempt to auto-detect it.
Auto-detection expects that you're running the `com.devture.ansible.role.postgres role`.
Auto-detection expects that you're running the `postgres role`.
You either need to run Postgres via that role, or you need to set `backup_borg_postgres_version` manually.
when: devture_postgres_enabled is not defined
when: postgres_enabled is not defined

- name: Fail with devture_postgres_enabled not enabled
- name: Fail with postgres_enabled not enabled
ansible.builtin.fail:
msg: >-
You are not running a built-in Postgres server (`devture_postgres_enabled: false`), so auto-detecting its version and setting `backup_borg_postgres_version` automatically based on that cannot happen.
You are not running a built-in Postgres server (`postgres_enabled: false`), so auto-detecting its version and setting `backup_borg_postgres_version` automatically based on that cannot happen.
Consider setting `backup_borg_postgres_version` to your Postgres version manually.
when: not devture_postgres_enabled
when: not postgres_enabled

- ansible.builtin.include_role:
name: "{{ backup_borg_postgresql_version_detection_devture_postgres_role_name }}"
name: "{{ backup_borg_postgresql_version_detection_postgres_role_name }}"
tasks_from: detect_existing_postgres_version

- debug:
msg: "Detected Postgres version: {{ postgres_detected_version }}"

- name: Fail if detected Postgres version is unsupported
ansible.builtin.fail:
msg: "You cannot use borg backup with such an old version ({{ devture_postgres_detected_version }}) of Postgres. Consider upgrading - link to docs for upgrading Postgres: docs/maintenance-postgres.md#upgrading-postgresql"
when: "devture_postgres_detected_version not in backup_borg_supported_postgres_versions"
msg: "You cannot use borg backup with Postgres v{{ postgres_detected_version }}. If you are using an old Postgres version, consider upgrading - link to docs for upgrading Postgres: docs/maintenance-postgres.md#upgrading-postgresql HOWEVER, if you are using a new Postgres version, there is a high chance that the version is not supported by borg backup yet (supported versions: {{ backup_borg_supported_postgres_versions }}). You can't do anything with that, details: https://github.com/etkecc/borgmatic/pull/1"
when: "postgres_detected_version not in backup_borg_supported_postgres_versions"

- name: Set the correct borg backup version to use
ansible.builtin.set_fact:
backup_borg_postgres_version: "{{ devture_postgres_detected_version }}"
backup_borg_postgres_version: "{{ postgres_detected_version }}"

- name: Ensure borg docker data paths exist
ansible.builtin.file:
Expand Down
2 changes: 1 addition & 1 deletion upstream
Submodule upstream updated 1 files
+1 −1 requirements.yml

0 comments on commit f3f1df2

Please sign in to comment.