Migrate a GeoNode 1.2 instance

In case you have an existing GeoNode 1.2 instance and you want to migrate it to latest version (2.0), this document should help you to get the desired result.

The migrations will move all your data to the new database schema as well as update your geoserver to the version 2.4.

Beware that the migrations only work if you are using PostgreSql as database backend!

Before starting

Before proceding with the following instructions, make sure to backup your Django database and your GeoServer data directory.

GeoNode 2.0 installation

As a first step, install GeoNode 2.0 and make it sure everything works smoothly using a new Django database. When asked to overwrite the local_settings file and the apache geonode site answer “yes” to both of them.

You shoud expect a database connection error during the installation process. This is the correct behavior for the migration purpose.

Now change the /etc/geonode/local_settings.py file, and set the DATABASE password to the GeoNode Dababase path of the 1.2 version.

GeoServer configuration

Remove the old GeoServer 2.2 instance from your servlet container.

Deploy the included GeoServer 2.4 to your servlet container (you can find it in the geonode/downloaded/geoserver.war). Then replace the GeoServer data directory with the one from the old GeoServer instance.

After stopping your servlet container, remove the security directory in the deployed geoserver/data directory and replace it with the security directory included in the geonode/geoserver/geoserver/data directory.

Edit the security/auth/geonodeAuthProvider/config.xml file and set the <baseUrl> element to the url where GeoNode is running

In case you are using a PostGIS data store, edit the PostGIS store in the geoserver/data/workspace directory and change the password to your current one. Don’t forget, when everything is working, to change it again from the GeoServer admin, in order to encrypt your password.

For example, edit this file (the data store name, uploaded, could be different in your case):

$ vi geoserver/data/workspaces/geonode/uploaded/datastore.xml

and then change this element:

<entry key="passwd">crypt1:+r9dV97SpWKB1m5pIjcvcw==</entry>

to:

<entry key="passwd">yourpassword</entry>

Restart your servlet container and check if GeoServer is working properly. For example, try the preview for some of the layers.

Migrate the Django database

With GeoServer up and running, truncate the south_migrationhistory table:

$ psql -c 'TRUNCATE TABLE south_migrationhistory;' -d geonode

Add the spatial columns to your database. If you have chosen a different database as datastore in the local_settings.py then add them on that one.

$ psql -U geonode -d geonode -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql

$ psql -U geonode -d geonode -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

$ psql -U geonode -d geonode -c ‘GRANT ALL ON geometry_columns TO PUBLIC;’

$ psql -U geonode -d geonode -c ‘GRANT ALL ON spatial_ref_sys TO PUBLIC;’

Run the syncdb command:

$ geonode syncdb

Now you will need to fake some application migrations and then migrate:

$ geonode migrate taggit --fake 0001
$ geonode migrate maps --fake 0001
$ geonode migrate
$ sudo geonode-updateip yourhost

Restart the web server:

$ sudo service apache2 restart

The procedure should completely migrate the database to a fresh 2.0 instance

Generate thumbnails and sync metadata and styles for layers

Now generate the missing thumbnails and sync metadata and styles for all of the layers, by running the updatelayers command:

$ geonode updatelayers