From 75662652c795e78a6385549d83f0812698ee573c Mon Sep 17 00:00:00 2001 From: ace Date: Mon, 31 Jul 2023 23:44:44 +0300 Subject: [PATCH] fix restore --- defaults/main.yaml | 5 +++++ tasks/restore.yaml | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/defaults/main.yaml b/defaults/main.yaml index fb4e2d2..d6fb75f 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -22,6 +22,10 @@ postgresql_wal_g_restore_config_name: ".walg-restore.json" postgresql_wal_g_pitr: 'latest' postgresql_wal_g_restore_backup_name: 'LATEST' postgresql_wal_g_binary_name: "wal-g-pg" +#postgresql_postgresql_archive_command: "wal-g wal-push %p" +#postgresql_postgresql_restore_command: "wal-g wal-fetch %f %p" +#postgresql_restore_dbs_from_backup_command: "wal-g backup-fetch {{ postgresql_wal_g_restore_backup_name }}" +#postgresql_restore_wals_from_backup_command: "wal-g wal-fetch %f %p" postgresql_recovery_target_time: "" postgresql_promote_trigger_file: "{{ postgresql_data_dir }}/promote.trigger" @@ -68,6 +72,7 @@ postgresql_restore_parameters: postgresql_log_dir: "/var/log/postgresql" + postgresql_supported_versions: - 13 - 14 diff --git a/tasks/restore.yaml b/tasks/restore.yaml index b10d9eb..b8fedde 100644 --- a/tasks/restore.yaml +++ b/tasks/restore.yaml @@ -19,7 +19,7 @@ state: directory become_user: postgres -- name: Check if d folder is empty before proceeding +- name: Check if database folder is empty before proceeding find: paths: "{{ postgresql_data_dir }}" register: postgresql_files_found @@ -29,13 +29,13 @@ - postgresql_files_found.matched == 0 block: - name: Restore database dir from backup - shell: "{{ postgresql_wal_g_binary_name ~ ' --config ' ~ postgresql_home_dir ~ '/' ~ postgresql_wal_g_restore_config_name ~ ' backup-fetch ' ~ postgresql_data_dir ~ ' ' ~ postgresql_wal_g_restore_backup_name }}" + shell: "{{ postgresql_restore_dbs_from_backup_command }}" become_user: postgres - name: Include PostgreSQL configuration vars: postgresql_archive_command: "cd ." - postgresql_restore_command: "{{ postgresql_wal_g_binary_name ~ ' --config ' ~ postgresql_home_dir ~ '/' ~ postgresql_wal_g_restore_config_name ~ ' wal-fetch %f %p' }}" + postgresql_restore_command: "{{ postgresql_restore_wals_from_backup_command }}" include_tasks: config.yaml - name: Create recovery.signal file