Обсуждение: Restore Windows dump to Linux (locale issue)

Поиск
Список
Период
Сортировка

Restore Windows dump to Linux (locale issue)

От
Ertan Küçükoglu
Дата:
Hello,

I am using PostgreSQL 18.1 on a Windows system.
I need to move that database to a Linux system of the same version number.

Windows system use locales name as tr-TR (this is UTF-8 locale)
Linux system use locale name as tr_TR.UTF-8

My cluster backup gives error at restore (I think because of that locale naming difference) as below

psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

And a bunch of other errors below.

What can I do to complete this migration?

Thanks & Regards,
Ertan

Re: Restore Windows dump to Linux (locale issue)

От
Adrian Klaver
Дата:
On 11/23/25 13:41, Ertan Küçükoglu wrote:
> Hello,
> 
> I am using PostgreSQL 18.1 on a Windows system.
> I need to move that database to a Linux system of the same version number.
> 
> Windows system use locales name as tr-TR (this is UTF-8 locale)
> Linux system use locale name as tr_TR.UTF-8
> 
> My cluster backup gives error at restore (I think because of that locale 
> naming difference) as below

What was the complete command you gave to do the dump?

> 
> psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

What objects where the errors on?

> 
> And a bunch of other errors below.
> 
> What can I do to complete this migration?
> 
> Thanks & Regards,
> Ertan


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Restore Windows dump to Linux (locale issue)

От
Adrian Klaver
Дата:
On 11/23/25 13:41, Ertan Küçükoglu wrote:
> Hello,
> 
> I am using PostgreSQL 18.1 on a Windows system.
> I need to move that database to a Linux system of the same version number.
> 
> Windows system use locales name as tr-TR (this is UTF-8 locale)
> Linux system use locale name as tr_TR.UTF-8
> 
> My cluster backup gives error at restore (I think because of that locale 
> naming difference) as below
> 
> psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

I should have added to previous post what does, in psql, the below return:

\l <database_name>

> 
> And a bunch of other errors below.
> 
> What can I do to complete this migration?
> 
> Thanks & Regards,
> Ertan


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Restore Windows dump to Linux (locale issue)

От
Tom Lane
Дата:
=?UTF-8?B?RXJ0YW4gS8O8w6fDvGtvZ2x1?= <ertan.kucukoglu@gmail.com> writes:
> I am using PostgreSQL 18.1 on a Windows system.
> I need to move that database to a Linux system of the same version number.
> Windows system use locales name as tr-TR (this is UTF-8 locale)
> Linux system use locale name as tr_TR.UTF-8
> My cluster backup gives error at restore (I think because of that locale
> naming difference) as below
> psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

Edit the dump so that the databases are created with Linux-compatible
locale names.  You should find lines like

CREATE DATABASE foo WITH TEMPLATE = template0 ENCODING = 'UTF-8' LOCALE_PROVIDER = libc LOCALE = 'tr-TR';

(details will vary depending on PG version) and changing the locale
strings ought to do the trick.

If the dump file is too big for your editor, consider splitting it
into schema-only and data-only dumps.

            regards, tom lane



Re: Restore Windows dump to Linux (locale issue)

От
Brent Wood
Дата:
If the dump file is too big to edit conventionally, piping it through a stream editor like sed to make the required changes works nicely.
It can be done on the fly in the restore process if required.

Brent Wood

Principal Technician, Fisheries
NIWA
DDI:  +64 (4) 3860529

From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Monday, 24 November 2025 11:02
To: Ertan Küçükoglu <ertan.kucukoglu@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Restore Windows dump to Linux (locale issue)
 
Ertan Küçükoglu <ertan.kucukoglu@gmail.com> writes:
> I am using PostgreSQL 18.1 on a Windows system.
> I need to move that database to a Linux system of the same version number.
> Windows system use locales name as tr-TR (this is UTF-8 locale)
> Linux system use locale name as tr_TR.UTF-8
> My cluster backup gives error at restore (I think because of that locale
> naming difference) as below
> psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

Edit the dump so that the databases are created with Linux-compatible
locale names.  You should find lines like

CREATE DATABASE foo WITH TEMPLATE = template0 ENCODING = 'UTF-8' LOCALE_PROVIDER = libc LOCALE = 'tr-TR';

(details will vary depending on PG version) and changing the locale
strings ought to do the trick.

If the dump file is too big for your editor, consider splitting it
into schema-only and data-only dumps.

                        regards, tom lane



Brent Wood
Principal Technician - GIS and Spatial Data Management
+64-4-386-0529
301 Evans Bay Parade, Greta Point, Hataitai, Wellington, New Zealand
Earth Sciences New Zealand
Earth Sciences New Zealand
The Institute of Geological and Nuclear Sciences Limited and the National Institute of Water and Atmospheric Research Limited joined to become the New Zealand Institute for Earth Science Limited. We are known as Earth Sciences New Zealand. For more information on the Earth Sciences transition click here.

Notice: This email may contain information which is confidential and/or subject to copyright, and may not be used, published or redistributed without the prior written consent of Earth Sciences New Zealand. If you are not the intended recipient, please immediately notify the sender and delete the email and any attachments. Any opinion or views expressed in this email are those of the individual sender and may not represent those of Earth Sciences New Zealand.

For information about how we process data and monitor communications please see our privacy policy.

Re: Restore Windows dump to Linux (locale issue)

От
Ertan Küçükoglu
Дата:
Brent Wood <Brent.Wood@niwa.co.nz>, 24 Kas 2025 Pzt, 01:42 tarihinde şunu yazdı:
If the dump file is too big to edit conventionally, piping it through a stream editor like sed to make the required changes works nicely.
It can be done on the fly in the restore process if required.

Brent Wood

Principal Technician, Fisheries
NIWA
DDI:  +64 (4) 3860529

From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Monday, 24 November 2025 11:02
To: Ertan Küçükoglu <ertan.kucukoglu@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Restore Windows dump to Linux (locale issue)
 
Ertan Küçükoglu <ertan.kucukoglu@gmail.com> writes:
> I am using PostgreSQL 18.1 on a Windows system.
> I need to move that database to a Linux system of the same version number.
> Windows system use locales name as tr-TR (this is UTF-8 locale)
> Linux system use locale name as tr_TR.UTF-8
> My cluster backup gives error at restore (I think because of that locale
> naming difference) as below
> psql:/db.dump:133: ERROR:  invalid LC_COLLATE locale name: "tr-TR"

Edit the dump so that the databases are created with Linux-compatible
locale names.  You should find lines like

CREATE DATABASE foo WITH TEMPLATE = template0 ENCODING = 'UTF-8' LOCALE_PROVIDER = libc LOCALE = 'tr-TR';

(details will vary depending on PG version) and changing the locale
strings ought to do the trick.

If the dump file is too big for your editor, consider splitting it
into schema-only and data-only dumps.

                        regards, tom lane

Hello,

I manually created a database on the Linux system.
Took a database backup and restored it on the Linux system.
This way dump does not include any charset.

Thanks & Regards,
Ertan

Re: Restore Windows dump to Linux (locale issue)

От
Adrian Klaver
Дата:
On 11/25/25 13:06, Ertan Küçükoglu wrote:

> 
> Hello,
> 

I am not understanding the below.

> I manually created a database on the Linux system.
> Took a database backup and restored it on the Linux system.

That is what started this thread, an issue with a backup from a Windows 
machine.

So where did you get a backup that you could restore?

> This way dump does not include any charset.

Pretty sure it does, it just one that your Linux machine understands.

> 
> Thanks & Regards,
> Ertan


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Restore Windows dump to Linux (locale issue)

От
Ertan Küçükoglu
Дата:
Adrian Klaver <adrian.klaver@aklaver.com>, 26 Kas 2025 Çar, 00:20 tarihinde şunu yazdı:
On 11/25/25 13:06, Ertan Küçükoglu wrote:

>
> Hello,
>

I am not understanding the below.

> I manually created a database on the Linux system.
> Took a database backup and restored it on the Linux system.

That is what started this thread, an issue with a backup from a Windows
machine.

So where did you get a backup that you could restore?


Initially it was a pgdump_all backup. Which includes database creation scripts.
I used only pg_dump backup. Where I restore in an already created database.

I called pg_dumpall backup as "cluster backup" . It may be my wrong choice of naming. 

Re: Restore Windows dump to Linux (locale issue)

От
Adrian Klaver
Дата:
On 11/25/25 14:03, Ertan Küçükoglu wrote:
> Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>>, 26 Kas 2025 Çar, 00:20 tarihinde 
> şunu yazdı:
> 
>     On 11/25/25 13:06, Ertan Küçükoglu wrote:
> 
>      >
>      > Hello,
>      >
> 
>     I am not understanding the below.
> 
>      > I manually created a database on the Linux system.
>      > Took a database backup and restored it on the Linux system.
> 
>     That is what started this thread, an issue with a backup from a Windows
>     machine.
> 
>     So where did you get a backup that you could restore?
> 
> 
> Initially it was a pgdump_all backup. Which includes database creation 
> scripts.
> I used only pg_dump backup. Where I restore in an already created database.

Alright I understand now.

> 
> I called pg_dumpall backup as "cluster backup" . It may be my wrong 
> choice of naming.

It is a dump of the all the databases in the cluster as well as the 
cluster global objects, so the naming is correct. I just did not make 
the connection.


-- 
Adrian Klaver
adrian.klaver@aklaver.com