Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jE5Dr-0007cg-22 for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 05:57:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jE5Dp-0007en-SJ for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 05:57:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jE5Dp-0007eg-Hs for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 05:57:01 +0000 Received: from [162.222.244.8] (helo=net153.net) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jE5Dh-000357-PK for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 05:57:00 +0000 Received: from [IPv6:2001:470:b965:1:c9:f5b0:27ca:ad56] (unknown [IPv6:2001:470:b965:1:c9:f5b0:27ca:ad56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by net153.net (Postfix) with ESMTPSA id DEFEC9C1 for ; Tue, 17 Mar 2020 00:56:48 -0500 (CDT) Subject: Re: Invalid byte sequence errors on DB restore To: pgsql-general@lists.postgresql.org References: <2c81203a-01ef-ca84-1294-91420f71dd1f@net153.net> <6dfc015b-54e6-37a0-4e5d-f22bfb15e64e@aklaver.com> From: Samuel Smith Message-ID: <361d28e0-bb5f-3ff7-4e35-2a87eb71bf46@net153.net> Date: Tue, 17 Mar 2020 00:56:48 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <6dfc015b-54e6-37a0-4e5d-f22bfb15e64e@aklaver.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 162.222.244.8 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/16/20 9:33 AM, Adrian Klaver wrote: > On 3/15/20 9: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? > > What are the locale and encodings set to for the instance and databases > in it? > >> >> Regards, >> Samuel Smith >> >> > > The server is in UTF8. The file made with pg_dump used 'SQL_ASCII', but setting it to UTF8 (via SET client_encoding ) did not help either. Having the pg_dump encoding set to 'latin1' seems to allow the file created it by it to be loaded via psql -f and everything seems to work. Is there any bad side to setting the encoding on pg_dump to latin1? For the record, the problem characters are: https://www.htmlsymbols.xyz/unicode/U+00D7 and https://www.htmlsymbols.xyz/unicode/U+00A0 But those characters were in many places and not all were issues. They only fail depending on the characters that precede it which makes it complicated. Thanks, Samuel Smith