From: Samuel Smith <pgsql@net153.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Invalid byte sequence errors on DB restore
Date: Thu, 19 Mar 2020 17:12:13 -0500
Message-ID: <7813515f-0872-9cfa-7cbb-b6675610744e@net153.net> (raw)
In-Reply-To: <2c81203a-01ef-ca84-1294-91420f71dd1f@net153.net>
References: <2c81203a-01ef-ca84-1294-91420f71dd1f@net153.net>
On 3/15/20 11:18 PM, Samuel Smith wrote:
> My current DB backup routine is just to call pg_dump and pipe to gzip.
> We recently started to get a failure to restore (which is basically just
> using psql -f on the pg_dump file) with the following errors:
>
> invalid byte sequence for encoding "UTF8": 0xa0
> and
> invalid byte sequence for encoding "UTF8": 0xd7 0x20
>
>
> This is on a pg 9.2.24 instance. Any tips to troubleshoot?
>
> Regards,
> Samuel Smith
>
>
Our issue actually turned out to be that a couple of our production
database had the encoding set to SQL_ASCII while all of our development
servers had UTF-8. This meant in some cases where we would restore a
production database into development (for testing or bug hunting), there
would be a failure to parse the backup file. A similar issue to this
blog post:
https://www.endpoint.com/blog/2017/07/21/postgres-migrating-sqlascii-to-utf-8
So our fix was to dump the affected production databases using the
LATIN1 encoding for pg_dump followed by destroying and recreating the
database and setting its new encoding to UTF-8. Then we could restore
the data using the pg_dump file with LATIN1 encoding.
Regards,
Samuel Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pgsql@net153.net
Subject: Re: Invalid byte sequence errors on DB restore
In-Reply-To: <7813515f-0872-9cfa-7cbb-b6675610744e@net153.net>
References: <2c81203a-01ef-ca84-1294-91420f71dd1f@net153.net> <7813515f-0872-9cfa-7cbb-b6675610744e@net153.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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