Moving a Nexus Repo 3 Instance to a New Location

 To move a Nexus Repo 3 server to a new location you'll need to move three main things after NXRM is gracefully stopped:

  1. The application directory (e.g. nexus-3.13.0-01)
  2. The data directory (e.g. sonatype-work/nexus3 )
  3. Blob storage

Application Directory

The application directory of a Nexus Repo 3 installation is portable*, and can simply be copied to the new location. Be sure to preserve operating system file permissions when doing this. 

Data Directory

The data directory ( commonly referred to as $data-dir or ${} ) of a Nexus Repo 3 installation is portable*, and can just be copied to a new location.   If you're not sure where the data directory of your installation is located, we have an article that can help you

DO NOT move the following directories within the $data-dir:

  • cache - temporary files instance specific
  • tmp - temporary files are instance specific

Cautiously move these directories within the $data-dir:

  • elasticsearch

If your last shutdown of the source was not graceful ( abrupt termination ), or in cases files are copied while source NXRM is running, then starting the new target instance with these files present may

  • result in corruption of the Search and Browse views, and certain REST API results in the target instance
  • prevent startup of the target instance

If startup fails or corruption occurs in the target instance due to elasticsearch errors, simply delete the elasticsearch directory in the target and when the target instance restarts, elasticsearch indexes will automatically rebuild.

Optionally move these from $data-dir:

  • logs - logs could be kept instance specific, or if you want to preserve the long term history of a moved instance, include moving these files to the new host

Blob Stores

Blob stores are also portable, and can be copied to a new location. 

File based blob stores: To find the location of your blob stores go to "repository --> blob stores" in the Nexus Repo 3 administration UI.  If the path shown for a blob store is not an absolute path, that means it is located at a relative directory under $data-dir/blobs/, and it will be copied when you copy the entire data directory.

If your blob stores are not going to be in the same location as they were in the original system running Nexus Repo you'll need to update their locations in the database.  See here for information on how to do this:

General Advice

Note that the directories must be copied when Nexus Repo is not running. But to minimize downtime, consider using a backup tool that can perform incremental file system backups. One commonly used tool which can do this is the "rsync" program that can be found in Linux distributions.

When using a backup tool that can perform incremental backups an initial copy of the directories can be done while the original Nexus Repo 3 is still running.  If you're using rsync, this can be done with "rsync -avP <source> <dest>".  Once this completes, shut down Nexus Repository Manager, and run a second copy using "rsync -avP --del <source> <dest>".  This second copy should run quite quickly, since rsync will only be handling the delta of files between the first and second copy.

If your original system has a slow disk consider running the first rsync with "ionice -c3 rsync". This will prevent rsync from consuming all disk bandwidth.

* Note: If you've made customizations to the files in the "etc" directory in either the install or work directories be sure to check and see if any absolute paths have been used.  These may need to be adjusted in the new installation.

Have more questions? Submit a request


Article is closed for comments.