Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olGOR-0002nV-OQ for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 21:14:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olGOP-0008ET-S5 for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 21:14:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olGOP-0008EK-HM for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 21:14:25 +0000 Received: from mout-u-107.mailbox.org ([2001:67c:2050:101:465::107]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olGOM-0001cE-QA for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 21:14:24 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4Mt3Q20Jtsz9sR7; Wed, 19 Oct 2022 23:14:18 +0200 (CEST) Date: Wed, 19 Oct 2022 23:14:17 +0200 (CEST) From: Erik Wienhold To: ertan.kucukoglu@1nar.com.tr, pgsql-general@lists.postgresql.org Message-ID: <974394104.123281.1666214057437@office.mailbox.org> In-Reply-To: <011701d8e3d1$80a6ba70$81f42f50$@1nar.com.tr> References: <011701d8e3d1$80a6ba70$81f42f50$@1nar.com.tr> Subject: Re: Cannot restore windows dump on linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 19/10/2022 17:43 CEST ertan.kucukoglu@1nar.com.tr wrote: > > I am using PostgreSQL 14.5 > > I tried to move a Linux database to Windows. Both identical version. > Linux dump successfully loaded on Windows system. > Reason for changing system didn=E2=80=99t work out and now I am trying to= move it back > because it has some modifications. > I just dumped a database backup on windows to a dump file. I see dump fil= e > contains =E2=80=9C\r\n=E2=80=9D as new line identifier (hence windows dum= p). Just to clarify, > this is not \N character I am mixing. > When I try to restore windows dump on regular Linux system, I get a lot o= f > errors and it stops at this one below where this is a pure data load posi= tion. > > ERROR: syntax error at or near "43589" > LINE 1: 43589 7102e523-f401-4cce-852d-e537f863886f=E2=80=A6 > > I also tried to stop at first error when restoring, in this case it stops= at > below error > > root@app:/home/ek# psql -v ON_ERROR_STOP=3D1 -U myuser -d mydb < last_bac= kup.bak > SET > SET > SET > SET > SET > set_config > ------------ > > (1 sat=C4=B1r) > > SET > SET > SET > SET > ERROR: index "ix_xrates_date" does not exist > > I searched the internet and I could not solve my problem. > > How can I successfully dump on Widnows and restore on Linux? On Windows, did you run pg_dump with --file option or redirect the output t= o a file? =09pg_dump --file last_backup.bak -U myuser mydb vs. =09pg_dump -U myuser mydb > last_backup.bak The redirect variant tripped me up before because Windows 10 writes the fil= e as UTF-16 which is not expected by psql. I don't know if psql can be configur= ed to handle UTF-16. The redirect is also the cause for CRLF line endings. -- Erik