postgresql_db module zcat error restoring `sql.gz` files
#475 opened on May 17, 2023
Repository metrics
- Stars
- (142 stars)
- PR merge metrics
- (PR metrics pending)
Description
SUMMARY
When I use the dump option of the postgresql_db module to create a .sql.gz file, the restore mechanism generates an error claiming the file does not exist. It looks like a problem with the use of the underlying zcat utility because it does work if the target does not use gz compression, e.g. if the target is /tmp/dump.sql.
ISSUE TYPE
- Bug Report
COMPONENT NAME
module: community.postgresql.postgresql_db
state: restore
ANSIBLE VERSION
ansible [core 2.14.5]
config file = /Users/alan/Code/InformaticsMatters/ansible-gizmos/ansible.cfg
configured module search path = ['/Users/alan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/alan/Library/Caches/pypoetry/virtualenvs/ansible-gizmos-s2R2cgEh-py3.10/lib/python3.10/site-packages/ansible
ansible collection location = /Users/alan/.ansible/collections:/usr/share/ansible/collections
executable location = /Users/alan/Library/Caches/pypoetry/virtualenvs/ansible-gizmos-s2R2cgEh-py3.10/bin/ansible
python version = 3.10.8 (main, Oct 13 2022, 10:18:28) [Clang 13.0.0 (clang-1300.0.29.30)] (/Users/alan/Library/Caches/pypoetry/virtualenvs/ansible-gizmos-s2R2cgEh-py3.10/bin/python)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
N/A
CONFIGURATION
ANSIBLE_NOCOWS(/Users/alan/Code/InformaticsMatters/ansible-gizmos/ansible.cfg) = True
CONFIG_FILE() = /Users/alan/Code/InformaticsMatters/ansible-gizmos/ansible.cfg
OS / ENVIRONMENT
Running on the control machine: -
OS: macOS Big Sur Version 11.7.6
STEPS TO REPRODUCE
Dump a PostgreSQL DB to a sql.gz file: -
- name: Dumping database
community.postgresql.postgresql_db:
name: "{{ kdd_db_database }}"
state: dump
target: /tmp/dump.sql.gz
login_host: "127.0.0.1"
And then try and restore with: -
- name: Restoring database
community.postgresql.postgresql_db:
name: "{{ kdr_db_database }}"
state: restore
target: /tmp/dump.sql.gz
login_host: "127.0.0.1"
EXPECTED RESULTS
restore should work
ACTUAL RESULTS
restore fails claiming that there is no such file or directory.
TASK [k8s_database_restore : Restoring database ************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "cmd: ****", "msg": "zcat: can't stat: /tmp/datatier.sql.gz (/tmp/datatier.sql.gz.Z): No such file or directory\n", "rc": 1, "stdout": "", "stdout_lines": []}