diff --git a/changelogs/fragments/882-postgresql_db-restore-fix.yml b/changelogs/fragments/882-postgresql_db-restore-fix.yml new file mode 100644 index 00000000..e61b42eb --- /dev/null +++ b/changelogs/fragments/882-postgresql_db-restore-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - postgresql_db - restoring from ``.sql`` files would execute the file twice. The module now avoids using both ``--file`` and stdin redirection simultaneously (https://github.com/ansible-collections/community.postgresql/issues/882). \ No newline at end of file diff --git a/plugins/modules/postgresql_db.py b/plugins/modules/postgresql_db.py index 5976b80f..0724dd5d 100644 --- a/plugins/modules/postgresql_db.py +++ b/plugins/modules/postgresql_db.py @@ -646,7 +646,7 @@ def db_restore(module, target, target_opts="", else: if any(substring in cmd for substring in ['--format=Directory', '--format=Custom']): cmd = '{0} {1}'.format(cmd, shlex_quote(target)) - else: + elif '--file=' not in cmd: cmd = '{0} < {1}'.format(cmd, shlex_quote(target)) return do_with_password(module, cmd, password)