diff --git a/changelogs/fragments/681-restore-custom-format-as-file.yml b/changelogs/fragments/681-restore-custom-format-as-file.yml new file mode 100644 index 000000000..2b19502dc --- /dev/null +++ b/changelogs/fragments/681-restore-custom-format-as-file.yml @@ -0,0 +1,3 @@ +bugfixes: + - postgresql_db - ``restore`` custom format as file instead of stdin to allow the use of --job + flag in ``target_opts`` (https://github.com/ansible-collections/community.postgresql/issues/594). \ No newline at end of file diff --git a/plugins/modules/postgresql_db.py b/plugins/modules/postgresql_db.py index 925a8ceff..e131956f1 100644 --- a/plugins/modules/postgresql_db.py +++ b/plugins/modules/postgresql_db.py @@ -555,7 +555,7 @@ def db_restore(module, target, target_opts="", else: return p2.returncode, '', stderr2, 'cmd: ****' else: - if '--format=Directory' in cmd: + if any(substring in cmd for substring in ['--format=Directory', '--format=Custom']): cmd = '{0} {1}'.format(cmd, shlex_quote(target)) else: cmd = '{0} < {1}'.format(cmd, shlex_quote(target))