Create a Local Replica of UDD

As we can see from UDD main page, there is a dump available.

So if we want to do some test, maybe a local replica of UDD can be handy, and that's what this page will describe.

Install Needed Packages

UDD runs on PostgreSql, so we need to install it (if it's not already available):

sudo apt-get install postgresql

that installs always the current supported version (at the time of writing it's 8.4).

Then we need also to install:

$ apt-cache search plperl
postgresql-plperl-8.4 - PL/Perl procedural language for PostgreSQL 8.4
$ sudo apt-get install postgresql-plperl-8.4

and

$ apt-cache search debversion
postgresql-8.4-debversion - Debian version number type for PostgreSQL
$ sudo apt-get install postgresql-8.4-debversion

needed for packages version comparison.

Setup PostgreSql Server

Now we got an "empty" ?PostreSql db server, let's set up it a bit.

First we create some users/roles

$ sudo su postgres
$ createuser morph
Shall the new role be a superuser? (y/n) y

This is my user, with superuser powers to easy management, create your own.

$ createuser udd
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

This is the UDD user on the database, where the UDD objects will live.

We need to do these configurations with the user postgres, the owner of the db instance.

$ createdb -T template0 -E SQL_ASCII udd

We create the database, named 'udd', forcing the encoding to SQL_ASCII, since that's the format of the export. We base it off 'template0' because 'template1' (the default) might be set to UTF8 which prevents creation of new SQL_ASCII databases.

Import UDD Dump

Now we only need to download the dump and import it, with:

$ zcat /path/to/udd.sql.gz | sudo -u postgres psql udd 2>&1 | tee udd-import.log

that will import the dump into udd db redirecting messages to udd-import.log.

In case of error messages, you may identify the problematic query by issueing again the psql command with the "-e" option :

$ zcat /path/to/udd.sql.gz | sudo -u postgres psql -e udd 2>&1 | tee udd-import.log

Reimport UDD

If we already have a UDD replicated on our local machine and want to reimport the UDD dump, we need to:

$ dropdb udd
$ createdb -E SQL_ASCII udd
$ zcat /path/to/udd.sql.gz | psql udd

so simply drop the db, recreate it and import the dump again.