Skip to content

Upgrading from 2.x

Leading up the 3.0 release of ReadyMap there were an extremly large amount of changes made that upgrading a ReadyMap server in place more difficult. Most notably we moved from using South for database migrations to using built in Django migrations. Becuase these migrations must be consistent, it is not possible to take a very old database from Readymap and upgrade it all the way to the 3.x series. Your existing database needs to be migrated to right before we changed to the Django migrations.

We've put together Docker images that hope to simplify this process.

Step 1: Backing up your existing database

First, we need to backup your existing database.

You should be able to run the following command to back up your existing database.

pg_dump -U postgres -Fc readymap > readymap.db

Step 2: Launch a ReadyMap 2.2.23 system

ReadyMap 2.2.23 is the last version that supported South migrations, so we must migrate your database up to that version.

We will use Docker to simplify the upgrade process. Follow the guide here and make sure you have docker and docker-compose installed and running. You also must log into Docker Hub and have appropriate credentials for downloading ReadyMap images.

Create a directory called "readymap-upgrade"

mkdir readymap-upgrade

Now create a file called docker-compose.yml with the following contents

version: '2.0'
services:
  db:
    image: mdillon/postgis:9.1
  redis:
    image: redis
  readymap:
    image: pelicanmapping/readymap_server:2.2.23
    volumes:
      - /data:/data
      - /tiles:/tiles
    ports:
      - "8080:80"
    depends_on:
      - db
      - redis

You may have to change the path of /data and /tiles to reflect the paths on your local system.

The syntax for the volumes is localpath:dockerpath.

Start up ReadyMap 2.2.23

cd readymap-upgrade
docker-compose up -d

If all goes well, you'll be able to go to http://localhost:8080/readymap and have access to a ReadyMap 2.2.23 system.

We've used port 8080 here to avoid conflicting with an existing ReadyMap cluster running on port 80 if you've already started one. If you need to adjust the port change the 8080 to something that is available.

Step 3: Migrate your database

Take the readymap.db backup file you generated in step 1 and place it in your /data directory so that it's accessible within Docker.

mv readymap.db /data

Run the readymap_restore command to take your database backup and upgrade it to ReadyMap 2.2.23

docker-compose exec readymap readymap_restore /data/readymap.db

You'll be prompted to erase your existing database, which is blank at this point so go for it.

After a long wait depending on how big your database is, the restore process should be finished.

Step 4: Export your newly migrated database

Now that your database has been upgraded to ReadyMap 2.2.23 it's time to reexport it so we can bring it into the 3.x series.

docker-compose exec readymap readymap_backup /data/readymap-2.2.23.db

This will dump your database to /data/readymap-2.2.23.db and you'll be ready to import it into the 3.x series.

Step 5: Destroy your readymap 2.2.23 cluster.

You're done with ReadyMap 2.2.23 and can now destroy your cluster by running

docker-compose down

Step 6: Import your database to ReadyMap 3.x

Follow the instructions here to bring up a cluster with the latest ReadyMap.

Once you are done, you can import your newly exported database into ReadyMap

docker-compose exec readymap readymap_restore /data/readymap-2.2.23.db

When the import is complete it will complain with an error saying django_content_type already exists. This is ok, and just means that you need to run a different command to bring the South migrations to the Django migrations.

Run this command to correctly initialize the migrations.

docker-compose exec readymap /opt/readymap_server/manage.py migrate --noinput --fake-initial