Keeping PostGIS up to date: Compiling from source and updating databases.

Although it is usually preferable to stick with stable releases of PostGIS for production databases, there are good reasons to use recent development versions for raster processing.

Compiling from source on Ubuntu is quick and painless using default settings, providing all the libraries are available.

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get -y install proj.dev libgdal.dev
sudo apt-get install libgdal.dev libproj.dev libxml2-dev libgeos-dev 
sudo apt-get install libarmadillo-dev libpoppler-dev libepsilon-dev libexpat-dev liblzma-dev
wget http://postgis.net/stuff/postgis-2.2.0dev.tar.gz
tar xvzf postgis-2.2.0*tar.gz
cd postgis*dev
./configure
make
sudo make install

The loaders are compiled and just need installing.

cd postgis*dev*/loader
sudo make install
cd ..
cd ..
cd postgis*dev*/raster/loader
sudo make install

PLR can also be compiled from source.

wget https://github.com/jconway/plr/archive/master.zip
unzip master.zip
cd plr-master
USE_PGXS=1 make
sudo USE_PGXS=1 make install

Now to update a data base into which PostGIS has been installed though the extension mechanism

ALTER EXTENSION postgis UPDATE TO '2.2.0';
ALTER EXTENSION postgis_topology UPDATE TO '2.2.0';

If this does not work, for example if you have a database that installed PostGIS using the older SQL route, then you can upgrade through the backup and restore mechanism.
For example, to update a database called “reddeam”.

sudo -u postgres pg_dump reddeam > reddeam.backup
dropdb reddeam
createdb reddeam
psql -d reddeam -c "CREATE EXTENSION postgis;"
psql -d reddeam -c "CREATE EXTENSION postgis_topology;"
sudo -u postgres psql reddeam<reddeam.backup

You may need to add support for legacy functions if you used them.

More advise is avalailable here.

http://www.bostongis.com/blog/index.php?/archives/187-How-to-upgrade-your-database-to-PostGIS-2.0-let-me-count-the-ways.html

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s