Discussion:
can't restore database created with pg_dump
Eric Smith
2014-09-20 02:51:34 UTC
Permalink
All,

I created a backup using pg_dump, postgres 8.3. I'm trying to restore that into a new postgres 9.3.5 installation. I just created the default text format output with pg_dump, and am trying to restore using psql < dumpfile.

I have images saved as bytea, and I get the following error when trying to restore:

ERROR: invalid input syntax for type bytea.
CONTEXT: COPY images, line 8, column imageData: "MM\000*\003':\242\200?\300\0208$\026\015\007\204BaP\270d6\035\017\210Da\317\307\350\030\000\001\177\..."


On some of my installations the restore process works, and on some it fails. All installations are moving from 8.3 to 9.3.5. Any ideas?

Thanks,
Eric
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Adrian Klaver
2014-09-20 13:55:34 UTC
Permalink
Post by Eric Smith
All,
I created a backup using pg_dump, postgres 8.3. I'm trying to restore that into a new postgres 9.3.5 installation. I just created the default text format output with pg_dump, and am trying to restore using psql < dumpfile.
First, you should use the pg_dump command from 9.3.5 to dump the
Postgres 8.3 database, it will 'know' about new features. This leads to
the comments below.
Post by Eric Smith
ERROR: invalid input syntax for type bytea.
CONTEXT: COPY images, line 8, column imageData: "MM\000*\003':\242\200?\300\0208$\026\015\007\204BaP\270d6\035\017\210Da\317\307\350\030\000\001\177\..."
On some of my installations the restore process works, and on some it fails. All installations are moving from 8.3 to 9.3.5. Any ideas?
The default output format for bytea changed in 9.0:

http://www.postgresql.org/docs/9.3/interactive/datatype-binary.html

So did the handling of escape strings:

http://www.postgresql.org/docs/9.3/interactive/runtime-config-compatible.html#RUNTIME-CONFIG-COMPATIBLE-VERSION

standard_conforming_strings (boolean)

This controls whether ordinary string literals ('...') treat
backslashes literally, as specified in the SQL standard. Beginning in
PostgreSQL 9.1, the default is on (prior releases defaulted to off).
Applications can check this parameter to determine how string literals
will be processed. The presence of this parameter can also be taken as
an indication that the escape string syntax (E'...') is supported.
Escape string syntax (Section 4.1.2.2) should be used if an application
desires backslashes to be treated as escape characters.


My guess is that the installations differ on the escape string handling.
Again, I would think the best way to handle this is to use the 9.3
version of pg_dump.
Post by Eric Smith
Thanks,
Eric
--
Adrian Klaver
***@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Adrian Klaver
2014-09-20 17:56:52 UTC
Permalink
Thank you for the help!
For the archives, did you use the 9.3 pg_dump or change the string escaping?
Regards,
Eric
--
Adrian Klaver
***@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Eric Smith
2014-09-20 15:43:14 UTC
Permalink
Thank you for the help!

Regards,
Eric
Post by Eric Smith
All,
I created a backup using pg_dump, postgres 8.3. I'm trying to restore that into a new postgres 9.3.5 installation. I just created the default text format output with pg_dump, and am trying to restore using psql < dumpfile.
First, you should use the pg_dump command from 9.3.5 to dump the Postgres 8.3 database, it will 'know' about new features. This leads to the comments below.
Post by Eric Smith
ERROR: invalid input syntax for type bytea.
CONTEXT: COPY images, line 8, column imageData: "MM\000*\003':\242\200?\300\0208$\026\015\007\204BaP\270d6\035\017\210Da\317\307\350\030\000\001\177\..."
On some of my installations the restore process works, and on some it fails. All installations are moving from 8.3 to 9.3.5. Any ideas?
http://www.postgresql.org/docs/9.3/interactive/datatype-binary.html
http://www.postgresql.org/docs/9.3/interactive/runtime-config-compatible.html#RUNTIME-CONFIG-COMPATIBLE-VERSION
standard_conforming_strings (boolean)
This controls whether ordinary string literals ('...') treat backslashes literally, as specified in the SQL standard. Beginning in PostgreSQL 9.1, the default is on (prior releases defaulted to off). Applications can check this parameter to determine how string literals will be processed. The presence of this parameter can also be taken as an indication that the escape string syntax (E'...') is supported. Escape string syntax (Section 4.1.2.2) should be used if an application desires backslashes to be treated as escape characters.
My guess is that the installations differ on the escape string handling. Again, I would think the best way to handle this is to use the 9.3 version of pg_dump.
Post by Eric Smith
Thanks,
Eric
--
Adrian Klaver
--
http://www.postgresql.org/mailpref/pgsql-general
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Loading...