diff --git a/scripts/shinkan/shinkan-restore b/scripts/shinkan/shinkan-restore index a356167..674199e 100644 --- a/scripts/shinkan/shinkan-restore +++ b/scripts/shinkan/shinkan-restore @@ -101,12 +101,11 @@ def write_result(path, data): def psql_exec(tcfg, dbname, sql): cmd = [ - 'docker', 'exec', tcfg['db_container'], + 'docker', 'exec', '-i', tcfg['db_container'], 'sh', '-ec', - 'export PGPASSWORD="${POSTGRES_PASSWORD:-}"; ' - f'psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At -c ' + json.dumps(sql), + f'export PGPASSWORD="${{POSTGRES_PASSWORD:-}}"; exec psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At', ] - return subprocess.run(cmd, capture_output=True, text=True, timeout=60) + return subprocess.run(cmd, input=sql, capture_output=True, text=True, timeout=60) def drop_db_if_exists(tcfg, dbname):