Upgrading Neo4j


This page describes how to upgrade an existing Neo4j 4.4.x installation (as used by SECollab prior to version 5.3.0) to Neo4j 5.26.9. For a fresh install, use the other pages of this chapter instead, starting with Installing and configuring Neo4j.

Before you start: this upgrade cannot be downgraded once completed. Migrating a database to Neo4j 5's storage format (see below) is irreversible: the files can no longer be read by Neo4j 4.4.x afterwards, and there is no in-place downgrade path. Keep the backups made during this procedure (including data.backup and plugins.backup) and, ideally, a VM snapshot taken before you begin, until SECollab has been functionally validated on 5.26.9. If something goes wrong, the only way back is restoring those backups onto a reinstalled 4.4.43 runtime.

Prerequisites

Stop the application and the database

admin@server:~$ sudo systemctl stop tomcat
admin@server:~$ sudo systemctl stop neo4j

Back up the existing databases

Check the currently installed version:

neo4j@server:/opt/neo4j/neo4j$ cd $NEO4J_HOME
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j version
# neo4j 4.4.43

Using the 4.4.x neo4j-admin backup command, back up each existing database. On a 4.4.x installation the primary database is still named neo4j (it only becomes secollab after being restored into 5.26.9, below); the other databases present depend on your installation (typically at least trsreplica, and possibly audit):

neo4j@server:/opt/neo4j/neo4j$ mkdir -p ~/backup/
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin backup --backup-dir=~/backup/ --include-metadata=all --database=neo4j
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin backup --backup-dir=~/backup/ --include-metadata=all --database=trsreplica

Install the new binary alongside the old one

admin@server:/opt/neo4j$ sudo mv ~/neo4j-enterprise-*-unix.tar.gz .
neo4j@server:/opt/neo4j$ unlink /opt/neo4j/neo4j
neo4j@server:/opt/neo4j$ tar -xvf neo4j-enterprise-5.26.9-unix.tar.gz
neo4j@server:/opt/neo4j$ rm neo4j-enterprise-5.26.9-unix.tar.gz
neo4j@server:/opt/neo4j$ ln -s neo4j-enterprise-5.26.9 neo4j

Switch the shell/session to Java 21 at this point. Starting the new runtime under Java 11 fails with an error similar to "Unsupported Java 11.x detected."

Confirm the new version is in place:

neo4j@server:/opt/neo4j$ cd $NEO4J_HOME
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j version
# neo4j 5.26.9

Redeploy the plugins

If /var/lib/neo4j/data is a symlink pointing at the 4.4.x installation, archive the old data and plugins directories before recreating them:

neo4j@server:/opt/neo4j/neo4j$ mv /var/lib/neo4j/data /var/lib/neo4j/data.backup
neo4j@server:/opt/neo4j/neo4j$ mv /var/lib/neo4j/plugins /var/lib/neo4j/plugins.backup
neo4j@server:/opt/neo4j/neo4j$ mkdir -p /var/lib/neo4j/plugins

Do not skip this: explicitly copy the new SECollab plugin jar into the recreated plugins directory. It is not carried over automatically from plugins.backup, and forgetting this step leaves Neo4j looking healthy (service up, cypher-shell login working, SHOW DATABASES succeeding) while the SECollab OSLC extension is silently not loaded, breaking the SECollab ↔ Neo4j integration.

neo4j@server:/opt/neo4j/neo4j$ sudo cp /path/to/com.sodius.neo4j.oslc-*.jar /var/lib/neo4j/plugins
neo4j@server:/opt/neo4j/neo4j$ sudo chown neo4j:neo4j /var/lib/neo4j/plugins/com.sodius.neo4j.oslc-*.jar
neo4j@server:/opt/neo4j/neo4j$ ln -s /opt/neo4j/neo4j/labs/apoc-5.26.9-core.jar /var/lib/neo4j/plugins/apoc.jar

Accept the commercial license

neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin server license --accept-commercial

Migrate the configuration file

Neo4j 5.x provides a tool to convert the old 4.4.x neo4j.conf to the new key names (see Configuring a single Neo4j server for the resulting configuration):

neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin server migrate-configuration \
            --from-path="/opt/neo4j/neo4j-enterprise-4.4.43/conf" \
            --to-path="/opt/neo4j/neo4j/conf/"

The tool renames most dbms.* keys to server.* (directories, connectors, JVM flags), moves dbms.tx_state.memory_allocation to db.tx_state.memory_allocation, leaves the dbms.ssl.policy.* keys unchanged, and drops the obsolete dbms.jvm.additional=-XX:-UseBiasedLocking flag. It also recommends adding several new JVM flags:

server.jvm.additional=--add-opens=java.base/java.nio=ALL-UNNAMED
server.jvm.additional=--add-opens=java.base/java.io=ALL-UNNAMED
server.jvm.additional=--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
server.jvm.additional=--enable-native-access=ALL-UNNAMED

The tool preserves the old configuration as neo4j.conf.old for reference. It does not migrate the temp directory override; re-add it manually, after creating the directory:

neo4j@server:/opt/neo4j/neo4j$ mkdir -p /var/lib/neo4j/tmp
server.jvm.additional=-Djava.io.tmpdir=/var/lib/neo4j/tmp

Reset the administrator password

As with a fresh install, the admin password must be reset before the new runtime is started for the first time:

neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin dbms set-initial-password <password>

Start Neo4j and check connectivity

If /var/lib/neo4j/data was a symlink before the upgrade, recreate it pointing at the freshly created data directory. Then start Neo4j and verify connectivity, before stopping it again to restore the databases:

neo4j@server:/opt/neo4j/neo4j$ sudo systemctl start neo4j
neo4j@server:/opt/neo4j/neo4j$ $NEO4J_HOME/bin/cypher-shell -u neo4j
# enter the password you set in the previous step when prompted
neo4j@server:/opt/neo4j/neo4j$ sudo systemctl stop neo4j

Restore the databases

The first restore reads from the neo4j backup folder created earlier and writes into a new database named secollab:

neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin database restore --from-path=~/backup/neo4j --overwrite-destination=true secollab
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin database restore --from-path=~/backup/trsreplica --overwrite-destination=true trsreplica

Migrate the databases to the new storage format

This step is irreversible. Once a database is migrated with --to-format=block, its files can no longer be read by Neo4j 4.4.x. If you need to abandon the upgrade after this point, the only way back is restoring the pre-upgrade backups (and ideally a VM snapshot) onto a reinstalled Neo4j 4.4.43 runtime; there is no in-place downgrade.

neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin database migrate "secollab" \
            --force-btree-indexes-to-range \
            --to-format=block
neo4j@server:/opt/neo4j/neo4j$ ./bin/neo4j-admin database migrate "trsreplica" \
            --force-btree-indexes-to-range \
            --to-format=block

--force-btree-indexes-to-range converts the deprecated btree indexes used by 4.4.x to the range indexes required by Neo4j 5. --to-format=block switches the databases to Neo4j 5's new storage format.

Start Neo4j and recreate the SECollab account

neo4j@server:/opt/neo4j/neo4j$ sudo systemctl start neo4j

The migration above only migrates the store files; on the freshly-initialized system database, the secollab user, role and database registrations must be created again, the same way as for a fresh install (see Neo4j post-installation settings), plus the two databases themselves.

Password: in the steps below, replace the suggested password with a password specific to your installation.

Create /tmp/migrate-server-data.cypher with the following content:

CREATE USER secollab SET PASSWORD '<password>' CHANGE NOT REQUIRED SET STATUS ACTIVE;
GRANT ROLE architect TO secollab;
SHOW USERS;
GRANT CREATE DATABASE ON DBMS TO architect;
GRANT DROP DATABASE ON DBMS TO architect;
CREATE DATABASE secollab;
CREATE DATABASE trsreplica;
SHOW DATABASES;

If your certificate is not issued by a CA already trusted by the system, set JAVA_OPTS to point at the truststore created in Installing Neo4j, then apply the file and restore each database's metadata using the scripts generated by the migrate step under /var/lib/neo4j/data/scripts/<database>/restore_metadata.cypher:

neo4j@server:/opt/neo4j/neo4j$ export JAVA_OPTS="-Djavax.net.ssl.trustStore=/var/lib/neo4j/certificates/cacerts"
neo4j@server:/opt/neo4j/neo4j$ $NEO4J_HOME/bin/cypher-shell --address bolt://localhost:7687 --username neo4j --password <password> --encryption true < /tmp/migrate-server-data.cypher
neo4j@server:/opt/neo4j/neo4j$ $NEO4J_HOME/bin/cypher-shell --address bolt://localhost:7687 --username neo4j --password <password> \
  --database system --param "database => 'secollab'" \
  -f /var/lib/neo4j/data/scripts/secollab/restore_metadata.cypher
neo4j@server:/opt/neo4j/neo4j$ $NEO4J_HOME/bin/cypher-shell --address bolt://localhost:7687 --username neo4j --password <password> \
  --database system --param "database => 'trsreplica'" \
  -f /var/lib/neo4j/data/scripts/trsreplica/restore_metadata.cypher

Remove the temporary file afterwards:

neo4j@server:~$ rm /tmp/migrate-server-data.cypher

Verify the SECollab plugin actually loaded

A healthy systemctl status and a successful cypher-shell login do not confirm the SECollab plugin loaded, since neither exercises it. Explicitly check before considering the upgrade complete:

admin@server:~$ grep -i oslc /var/log/neo4j/debug.log

Alternatively, call a known OSLC endpoint exposed by SECollab through Neo4j. Add this check to your upgrade checklist alongside systemctl status and SHOW DATABASES.

Restart Tomcat and verify SECollab

admin@server:~$ sudo systemctl start tomcat

Log into SECollab and confirm project data, reviews and reports are all reachable before proceeding to cleanup.

Cleanup

Only once SECollab has been functionally validated on 5.26.9:

admin@server:~$ rm -Rf ~/backup
admin@server:~$ rm -Rf /opt/neo4j/neo4j-enterprise-4.4.43
admin@server:~$ rm -Rf /var/lib/neo4j/data.backup
admin@server:~$ rm -Rf /var/lib/neo4j/plugins.backup