Sonatype Nexus OrientDB to H2 migration in a docker-compose based setup
Based on the official Sonatype migration instructions but adapted for Docker and our 5-minute Nexus configuration
While I would prefer PostgreSQL to H2, it apparently requires a Nexus Pro license to use PostgreSQL, so we’re stuck with using H2 here.
mkdir -p nexus_logs nexus_sonatype_logs
chmod -R 777 nexus_logs nexus_sonatype_logs
Change docker-compose.yml
:
services:
nexus:
image: sonatype/nexus3:3.70.0
# ...
volumes:
- "./nexus_data:/nexus-data"
- "./nexus_sonatype_logs:/opt/sonatype/logs"
- "./nexus_logs:/logs"
# ...
Restart Nexus:
docker-compose up -d
Perform a full Nexus Backup using the Backup task Do not skip, this is required for the Migrator to run!
As backup location, use /nexus-data
(since this is mounted to the host and the migrator will need access to the backup files).
Schedule the backup task once, two minutes in the future.
Wait until it is finished
Shutdown Nexus:
docker-compose down -v
Download migrator tool. You need to use the 3.70 migrator tool version specifically - later versions will NOT work with OrientDB!
cd nexus_data
wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.2-01.jar
cd ..
Run migrator
docker-compose run -u root nexus /bin/bash -c 'chmod 777 /opt/sonatype && chmod -R 777 /opt/sonatype/logs && cp /nexus-data/*.bak /opt/sonatype && java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar /nexus-data/nexus-db-migrator-* --migration_type=h2 -y && cp /opt/sonatype/nexus.mv.db /nexus-data/db'
Now add the datastore config to nexus_data/etc/nexus.properties
:
nexus.datastore.enabled=true
After that, restart your Nexus and check if it works.
After you have verified that the migration was successful, remove the extra volumes from docker-compose.yml
:
- "./nexus_sonatype_logs:/opt/sonatype/logs" # Remove this line!
- "./nexus_logs:/logs" # Remove this line!
remove the actual directories:
rm -rf nexus_sonatype_logs nexus_logs
And restart Nexus again:
docker-compose down
docker-compose up -d
Also, you can now upgrade to 3.72.0
or later (which would not support OrientDB anymore) by changing the image version in docker-compose.yml
:
image: sonatype/nexus3:3.72.0