Sonatype Nexus Repository is a software repository manager, available under both an open-source license and a proprietary license.[1] It can combine repositories for various programming languages, so that a single server can be used as a source for building software. The open source version uses the H2 database.

Normally, upgrading Sonatype Nexus 3 only requires deleting the old container and mounting the data to run the new version of the image. However, since Sonatype Nexus 3 (from version 3.70.2 onwards) uses the H2 database, the upgrade cannot be done smoothly. Therefore, we need to manually migrate the database from OrientDB to H2.

Error info

-----------------------------------------------------------------------------
This instance is using a legacy Orient database. 
You must migrate to H2 or PostgreSQL before upgrading to this version. See our database migration help documentation at: 
https://links.sonatype.com/products/nxrm3/docs/unsupported-db.
-----------------------------------------------------------------------------

Official Documentation

3.71.0 and beyond do not support OrientDB:Sonatype Nexus Repository 3.71.0 Release Notes

Backup task:Configure and Run the Backup Task

Download db tool:3.70.x Downloads (for OrientDB)

Migrating db:Migrating to a New Database / Migrating to a New Database (Legacy Method for Pre-3.70.0)

Upgrade Process

#!/bin/bash

# stop old nexus
docker stop nexus

# if you can not download docker images, you can set docker proxy
cat /etc/docker/daemon.json 
{
    "proxies": {
      "http-proxy": "http://192.168.100.10:7890",
      "https-proxy": "http://192.168.100.10:7890",
      "no-proxy": "localhost,127.0.0.0/8,172.0.0.0/8,192.0.0.0/8"
    },
    "experimental" : true,
    "log-opts": {
      "max-size": "1024",
      "max-file": "5"
    }
}

# download nexus 3.70.2
docker pull sonatype/nexus3:3.70.2

# run nexus 3.70.2
docker run -v /nexus-data:/nexus-data -p 8081:8081 -p 9443:9443 --name nexus  -d sonatype/nexus3:3.70.2

# user admin user login nexus to backup data
login --- system --- tasks --- create task --- Create Admin - Export databases for backup Task
name: backup
backup location: /nexus-data/backup
task frequency: manual

# run backup task
login --- system --- tasks --- click backup task --- run

# perform data migration

# login nexus bash
docker exec -it nexus bash

# stop nexus
/opt/sonatype/nexus/bin/nexus stop

# check backup file
cd /nexus-data/backup
ls -ahl

# download nexus db tool
curl -s -L -O https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.2-01.jar

# update db to h2
java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.2-01.jar --migration_type=h2
ps: you may encounter insufficient memory. We need to execute the above command in a VM with sufficient memory to migrate data.

# move new db file to nexus data folder
cp nexus.mv.db /nexus-data/db

# stop nexus
/opt/sonatype/nexus/bin/nexus stop

# exit nexus bash
exit

# stop nexus container
docker stop nexus

# modify nexus config use h2 db
vi /nexus-data/etc/nexus.properties
nexus.datastore.enabled=true

# restart nexus container
docker start nexus

# check h2 db status
docker logs nexus | grep H2

# upgrade nexus3 to the latest version
docker pull sonatype/nexus3:3.72.0

# run nexus 3.72.0
docker run -v /nexus-data:/nexus-data -p 8081:8081 -p 9443:9443 --name nexus  -d sonatype/nexus3:3.70.2

Whether you are deploying traditionally or with Docker, the upgrade process is the same. The general steps involve backing up the database, using the official tool to upgrade the database based on the backup data, and then importing the upgraded database files.