pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Cannot restore windows dump on linux
3+ messages / 2 participants
[nested] [flat]

* Cannot restore windows dump on linux
@ 2022-10-19 15:43 ertan.kucukoglu@1nar.com.tr
  2022-10-19 16:42 ` RE: Cannot restore windows dump on linux ertan.kucukoglu@1nar.com.tr
  2022-10-19 21:14 ` Re: Cannot restore windows dump on linux Erik Wienhold <ewie@ewie.name>
  0 siblings, 2 replies; 3+ messages in thread

From: ertan.kucukoglu@1nar.com.tr @ 2022-10-19 15:43 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello,

 

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't 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 file
contains "\r\n" as new line identifier (hence windows dump). 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 of
errors and it stops at this one below where this is a pure data load
position.

 

ERROR:  syntax error at or near "43589"

LINE 1: 43589 7102e523-f401-4cce-852d-e537f863886f.

 

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=1 -U myuser -d mydb <
last_backup.bak

SET

SET

SET

SET

SET

set_config

------------

 

(1 satýr)

 

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?

 

Any help is appreciated.

 

Thanks & Regards,

Ertan

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* RE: Cannot restore windows dump on linux
  2022-10-19 15:43 Cannot restore windows dump on linux ertan.kucukoglu@1nar.com.tr
@ 2022-10-19 16:42 ` ertan.kucukoglu@1nar.com.tr
  1 sibling, 0 replies; 3+ messages in thread

From: ertan.kucukoglu@1nar.com.tr @ 2022-10-19 16:42 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello again,

While I was searching for a solution, I saw an example of manual running of
dump file within psql. Tried this and it did work just fine.

\connect mydb
\i last_backup.bak

Above two commands completed without any loading error at all.

Now I wonder why command line did not work.
Do let me know if there is a known reason, please.

Thanks & Regards,
Ertan


-----
From: ertan.kucukoglu@1nar.com.tr <ertan.kucukoglu@1nar.com.tr> 
Sent: Wednesday, October 19, 2022 18:43
To: pgsql-general@lists.postgresql.org
Subject: Cannot restore windows dump on linux

Hello,

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't 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 file
contains "\r\n" as new line identifier (hence windows dump). 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 of
errors and it stops at this one below where this is a pure data load
position.

ERROR:  syntax error at or near "43589"
LINE 1: 43589 7102e523-f401-4cce-852d-e537f863886f.

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=1 -U myuser -d mydb <
last_backup.bak
SET
SET
SET
SET
SET
set_config
------------

(1 satýr)

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?

Any help is appreciated.

Thanks & Regards,
Ertan







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Cannot restore windows dump on linux
  2022-10-19 15:43 Cannot restore windows dump on linux ertan.kucukoglu@1nar.com.tr
@ 2022-10-19 21:14 ` Erik Wienhold <ewie@ewie.name>
  1 sibling, 0 replies; 3+ messages in thread

From: Erik Wienhold @ 2022-10-19 21:14 UTC (permalink / raw)
  To: ertan.kucukoglu@1nar.com.tr; pgsql-general@lists.postgresql.org

> 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’t 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 file
> contains “\r\n” as new line identifier (hence windows dump). 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 of
> errors and it stops at this one below where this is a pure data load position.
>
> ERROR: syntax error at or near "43589"
> LINE 1: 43589 7102e523-f401-4cce-852d-e537f863886f…
>
> 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=1 -U myuser -d mydb < last_backup.bak
> SET
> SET
> SET
> SET
> SET
> set_config
> ------------
>
> (1 satır)
>
> 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 to
a file?

	pg_dump --file last_backup.bak -U myuser mydb

vs.

	pg_dump -U myuser mydb > last_backup.bak

The redirect variant tripped me up before because Windows 10 writes the file as
UTF-16 which is not expected by psql.  I don't know if psql can be configured
to handle UTF-16.  The redirect is also the cause for CRLF line endings.

--
Erik





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-10-19 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 15:43 Cannot restore windows dump on linux ertan.kucukoglu@1nar.com.tr
2022-10-19 16:42 ` ertan.kucukoglu@1nar.com.tr
2022-10-19 21:14 ` Erik Wienhold <ewie@ewie.name>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox