@ -78,7 +78,8 @@
# role (`matrix_postgres_connection_username`) and database (`matrix_postgres_db_name`) by itself on startup,
# role (`matrix_postgres_connection_username`) and database (`matrix_postgres_db_name`) by itself on startup,
# we need to remove these from the dump, or we'll get errors saying these already exist.
# we need to remove these from the dump, or we'll get errors saying these already exist.
- name : Perform Postgres database dump
- name : Perform Postgres database dump
ansible.builtin.command : >-
ansible.builtin.command:
cmd : >-
{{ matrix_host_command_docker }} run --rm --name matrix-postgres-dump
{{ matrix_host_command_docker }} run --rm --name matrix-postgres-dump
--log-driver=none
--log-driver=none
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
@ -90,6 +91,8 @@
-c "pg_dumpall -h matrix-postgres
-c "pg_dumpall -h matrix-postgres
{{ '| gzip -c ' if postgres_dump_name.endswith('.gz') else '' }}
{{ '| gzip -c ' if postgres_dump_name.endswith('.gz') else '' }}
> /out/{{ postgres_dump_name }}"
> /out/{{ postgres_dump_name }}"
register : matrix_postgres_upgrade_postgres_dump_command_result
changed_when : matrix_postgres_upgrade_postgres_dump_command_result.rc == 0
- name : Ensure matrix-postgres is stopped
- name : Ensure matrix-postgres is stopped
ansible.builtin.service:
ansible.builtin.service:
@ -97,7 +100,10 @@
state : stopped
state : stopped
- name : Rename existing Postgres data directory
- name : Rename existing Postgres data directory
ansible.builtin.command : "mv {{ matrix_postgres_data_path }} {{ postgres_auto_upgrade_backup_data_path }}"
ansible.builtin.command:
cmd : "mv {{ matrix_postgres_data_path }} {{ postgres_auto_upgrade_backup_data_path }}"
register : matrix_postgres_upgrade_postgres_move_command_result
changed_when : matrix_postgres_upgrade_postgres_move_command_result.rc == 0
- ansible.builtin.debug:
- ansible.builtin.debug:
msg : "NOTE: Your Postgres data directory has been moved from `{{ matrix_postgres_data_path }}` to `{{ postgres_auto_upgrade_backup_data_path }}`. In the event of failure, you can move it back and run the playbook with --tags=setup-postgres to restore operation."
msg : "NOTE: Your Postgres data directory has been moved from `{{ matrix_postgres_data_path }}` to `{{ postgres_auto_upgrade_backup_data_path }}`. In the event of failure, you can move it back and run the playbook with --tags=setup-postgres to restore operation."
@ -155,7 +161,10 @@
and restore the automatically-made backup (`mv {{ postgres_auto_upgrade_backup_data_path }} {{ matrix_postgres_data_path }}`).
and restore the automatically-made backup (`mv {{ postgres_auto_upgrade_backup_data_path }} {{ matrix_postgres_data_path }}`).
- name : Perform Postgres database import
- name : Perform Postgres database import
ansible.builtin.command : "{{ matrix_postgres_import_command }}"
ansible.builtin.command:
cmd : "{{ matrix_postgres_import_command }}"
register : matrix_postgres_upgrade_postgres_import_command_result
changed_when : matrix_postgres_upgrade_postgres_import_command_result.rc == 0
- name : Delete Postgres database dump file
- name : Delete Postgres database dump file
ansible.builtin.file:
ansible.builtin.file: