Convert OpenDNSSEC 1.4 database to OpenDNSSEC 2.0 database
==========================================================

The ODS2.0 database is set up very differently from the ODS1.4 database. We 
provide a couple of scripts to make the transition. Please review this 
document entirely before starting the conversation.

Requirements
------------

These scripts will work coming from ODS version 1.4.8.2 or 1.4.9. Earlier
versions are not supported. Please upgrade to one of these 2 versions before 
migration.

General preparation
-------------------

 * First stop OpenDNSSEC entirely.
 * You are strongly advised to backup /etc/opendnssec and
   /var/opendnssec before continuing.
 * Also prevent any nameserver from receiving updates from OpenDNSSEC until
   you are sure the migration was successful.
 * It is discouraged to perform the migration during a rollover. The migration
   script tries to deal with it as gracefully as possible though many corner
   cases exist. Generally it will not break the zone but unexpected behaviour
   may occur. If you do, and see unexpected state, the best way to deal with it
   is to start a rollover for the offending keytype.

Conversion Sqlite
-----------------

There are 2 relevant files for the conversion:

 * /usr/local/sbin/ods-migrate-sqlite3 - Conversion script
 * /usr/local/share/opendnssec/migration/migrate-sqlite.sql -
	Contains SQL statements, called by ods-migrate-sqlite3

Call the script like so: `/usr/local/sbin/ods-migrate-sqlite3 -i INPUT -o OUTPUT`.
Where INPUT is the kasp.db file commonly found in _/var/opendnssec/db/kasp.db_.
And OUTPUT is a non-existing file where the new database should go,
default location for OpenDNSSEC 2.x is _/var/opendnssec/kasp.db_.
On success, replace old database file with the new database file or adjust
_/etc/opendnssec/conf.xml_ accordingly.

Conversion MySQL
----------------
 
There are 2 relevant files for the conversion:

 * /usr/local/sbin/ods-migrate-mysql - Conversion script
 * /usr/local/share/opendnssec/migration/migrate-mysql.sql -
	Contains SQL statements, called by ods-migrate-mysql

Call the script like so:
`/usr/local/sbin/ods-migrate-mysql -i INPUT -o OUTPUT -h HOST -u USER -p PASSWORD`.
Where INPUT is the name of the existing database on HOST. And
OUTPUT is a non-existing database on the same host where the new database
should go. On success, replace old database with the new database file or
adjust _/etc/opendnssec/conf.xml_ accordingly.

Post Conversion
---------------

ODS 2.0 stores the keytags in the database, 1.4 unfortunately does not.
Therefore an additional tool is provided which calculates the keytags and
stores them in the database. Make sure that at this point _conf.xml_ points to
the new database. Then run `/usr/local/sbin/ods-migrate`.

Now your new database is ready for use. At this point the signer will refuse to
run because the file `/var/opendnssec/enforcer/zones.xml` does not exist
yet. In ODS 1.4 `/etc/opendnssec/zonelist.xml` is always on par with the
database contents (this is no longer true for 2.0) so it is safe to copy this
file over to the missing file.

If all went well you should be able to start OpenDNSSEC and review its output.
If applicable start any nameservers you stopped in the process. 
