Jenia Be Nice Please
Jenia Be Nice Please

Reputation: 2703

migrating from postgresql 9.3 to 9.4, postgis

I upgraded from postgresql 9.3 to 9.4 and now I want to migrate my data.

So this is what I tried to do. First I ran the old postgresql like so

/opt/pgsql-9.3/bin/pg_ctl -D /var/lib/postgres/data/ start

Then, I tried to dump the old database to a file:

/opt/pgsql-9.3/bin/pg_dumpall >> old_backup.sql

And it told me:

pg_dump: [archiver (db)] query failed: ERROR:  could not access file "$libdir/postgis-2.1": No such file or directory

So okay, I tried to find the postgis-2.1 files and copy them to the libdir

find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so
/usr/lib/postgresql/postgis-2.1.so
/usr/lib/postgresql/postgis-2.1 <-----

Okay, now what's the libdir?

/opt/pgsql-9.3/bin/pg_config --pkglibdir
/opt/pgsql-9.3/lib

So I made a symbolic link in /opt/pgsql-9.3/lib to here /usr/lib/postgresql/postgis-2.1:

 pwd
/opt/pgsql-9.3/lib
ls -l postgis-2.1
postgis-2.1 -> /usr/share/postgresql/contrib/postgis-2.1

But still I get the error: query failed: ERROR: could not access file "$libdir/postgis-2.1": No such file or directory

I'm kind of out of ideas. Maybe someone can help me?

I'm usnig arch linux

P.S

Postgis is installed:

pacman -S postgis
warning: postgis-2.1.5-1 is up to date -- reinstalling

And here are the binaries:

find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so   <---- binary
/usr/lib/postgresql/postgis-2.1.so     <----- binary
/opt/pgsql-9.3/lib/postgis-2.1         <----- that's the symlink from earlier
/usr/share/postgresql/contrib/postgis-2.1

Upvotes: 5

Views: 4614

Answers (3)

Googol
Googol

Reputation: 2933

I had the same problem. My solution with Docker was:

docker exec -i $(docker-compose ps -q postgis) ln -s /usr/lib/postgresql/9.6/lib/postgis-2.3.so /usr/lib/postgresql/9.6/lib/postgis-2.1.so

Upvotes: 0

AndreyT
AndreyT

Reputation: 1499

I have similar problem, but solve it a bit differently:

dbname=#\dx

  Name   | Version |   Schema   |                             Description
---------+---------+------------+---------------------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis | 2.1.5   | postgis    | PostGIS geometry, geography, and raster spatial types and functions


dbname=#ALTER EXTENSION postgis UPDATE TO '2.2.0';
dbname=#\dx

  Name   | Version |   Schema   |                             Description
---------+---------+------------+---------------------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis | 2.2.0   | postgis    | PostGIS geometry, geography, and raster spatial types and functions

Upvotes: 9

MatheusOl
MatheusOl

Reputation: 11875

The symbolic link is pointing to the "share" files, used for CREATE EXTENSION and family. What you need is to point the .so files inside the directory returned by pg_config --pkglibdir:

$ rm /opt/pgsql-9.3/lib/postgis-2.1 # it is a wrong link, so undo it
$ ln -s /usr/lib/postgresql/postgis-2.1.so /opt/pgsql-9.3/lib/

Now the PostGIS .so file will be in "$libdir" and you'll be able to perform pg_dumpall.

Of course keeping it that way does not strike me as sane setup, but as your upgrading I'm assuming this is just an intermediate state and you'll remove PostgreSQL 9.3 entirely after that. You must also verify if PostGIS is linked with 9.3 libraries, if not you might have some problems.

Upvotes: 5

Related Questions