Sonatype Nexus migration from built-in OrientDB to PostgreSQL in separate container
Note: This post is mostly just a collection of commands I’ve tried. I am not 100% sure what the correct way to do this is, but this worked out for me in the end. Ensure to backup your data before trying!
Based on the official Sonatype migration instructions and our 5-minute Nexus configuration but adapted for Docker.
Ensure Nexus is running in version 3.70.0 and add depends_on
to the Nexus service in docker-compose.yml
:
nexus:
image: sonatype/nexus3:3.70.0
# ...
depends_on:
- postgres
Add config for Postgres to .env
POSTGRES_DB=nexus
POSTGRES_USER=nexus
POSTGRES_PASSWORD=ahyath1thaem4Aedaemeoph5Aadohb
Add datastore config to nexus_data/etc/nexus.properties
:
nexus.datastore.enabled=true
Add PostgreSQL connection string to nexus_data/etc/fabric/nexus-store.properties
:
username=nexus
password=ahyath1thaem4Aedaemeoph5Aadohb
jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus
Add PostgreSQL container
services:
postgres:
image: postgres
restart: unless-stopped
volumes:
- ./pg_data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
Download migrator into mapped data directory
cd nexus_data
wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.72.0-01.jar
cd ..
Run migrator
docker-compose run nexus /bin/bash -c 'java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar /nexus-data/nexus-db-migrator-* --migration_type=postgres --db_url="jdbc:postgresql://postgres:5432/nexus?user=nexus&password=ahyath1thaem4Aedaemeoph5Aadohb"'