I am migrating the postgres version in my application from 9.6 to postgres 16. To do this, I have to migrate all the data in the postgres to newer version.
The approach I am trying is:
- Take dump from the existing postgres container using
pg_dumpall > pg_dump.sql
and copy it to the host machine usingdocker cp
. - Copy the dump file to new container running postgres 16.
- Run
psql -f /tmp/pg_dump.sql
to restore the data in new postgres version.
But the last command fails with a lot of errors like:
<code>psql:/tmp/pg_dump.sql:4992581: error: invalid command N
psql:/tmp/pg_dump.sql:4992582: error: invalid command N
psql:/tmp/pg_dump.sql:5477889: ERROR: syntax error at or near "A41"
LINE 1: A41,tiger:county,"Merrimack, NH",tiger:name_base,Province,ti...
psql:/tmp/pg_dump.sql:5624109: ERROR: syntax error at or near "Cold"
LINE 1: Cold River",tiger:name_type,Rd,tiger:reviewed,no}
^
psql:/tmp/pg_dump.sql:5630110: error: invalid command
psql:/tmp/pg_dump.sql:5631865: ERROR: syntax error at or near "Sa"
LINE 1: Sa 09:00-12:00",phone,+1-603-669-4956}
</code>
<code>psql:/tmp/pg_dump.sql:4992581: error: invalid command N
psql:/tmp/pg_dump.sql:4992582: error: invalid command N
psql:/tmp/pg_dump.sql:5477889: ERROR: syntax error at or near "A41"
LINE 1: A41,tiger:county,"Merrimack, NH",tiger:name_base,Province,ti...
psql:/tmp/pg_dump.sql:5624109: ERROR: syntax error at or near "Cold"
LINE 1: Cold River",tiger:name_type,Rd,tiger:reviewed,no}
^
psql:/tmp/pg_dump.sql:5630110: error: invalid command
psql:/tmp/pg_dump.sql:5631865: ERROR: syntax error at or near "Sa"
LINE 1: Sa 09:00-12:00",phone,+1-603-669-4956}
</code>
psql:/tmp/pg_dump.sql:4992581: error: invalid command N
psql:/tmp/pg_dump.sql:4992582: error: invalid command N
psql:/tmp/pg_dump.sql:5477889: ERROR: syntax error at or near "A41"
LINE 1: A41,tiger:county,"Merrimack, NH",tiger:name_base,Province,ti...
psql:/tmp/pg_dump.sql:5624109: ERROR: syntax error at or near "Cold"
LINE 1: Cold River",tiger:name_type,Rd,tiger:reviewed,no}
^
psql:/tmp/pg_dump.sql:5630110: error: invalid command
psql:/tmp/pg_dump.sql:5631865: ERROR: syntax error at or near "Sa"
LINE 1: Sa 09:00-12:00",phone,+1-603-669-4956}
Is there any compatibility issue between the two versions? I tried pg_restore
too, but that doesn’t execute anything and prompt gets stuck indefinitely.
2