Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I backup a nexus repository manager

Tags:

The nexus book: http://www.sonatype.com/books/nexus-book/reference/. Does not seem to spend any time on how one should go about backing up a nexus repository. If I am installing my snapshot and releases into this local repository, it seems that it would behoove me to back it up. However, I'm not really interested in backing up anything that can easily be downloaded from a remote repository.

Some google searches do not seem to reveal the canonical answer either, so perhaps for posterity it can be recorded here.

Thanks, Nathan

like image 656
Nathan Feger Avatar asked Apr 02 '09 16:04

Nathan Feger


People also ask

How do I backup my Nexus repository?

For those using OrientDB or H2 databases, Nexus Repository lets you use a scheduled task to aid with backing up your repository manager. Along with your backup procedure, you can configure Nexus Repository to save the OrientDB or H2 databases that store your component metadata and system configurations.

How do I download Nexus repository manager?

To download the latest Nexus Repository Manager OSS distribution, go to Sonatype's OSS download page and choose the compressed bundle file that suits your need from the Nexus Repository Manager OSS 2. x section. A download will begin to the latest version. Older versions can be found here if needed.

Where is Nexus configuration stored?

If you have modified the configuration of Nexus, that configuration is stored in sonatype-work/. If you've uploaded artifacts to hosted repositories, customized repository metadata, or proxied artifacts from remote repositories, all of that data is going to be stored in sonatype-work/.


1 Answers

When you install Nexus, you'll end up with two directories:

nexus-webapp-1.3.1.1/ sonatype-work/ 

We've separated the application from the data and configuration. The Nexus application is in nexus-webapp-1.3.1.1/ and the data and configuration is in sonatype-work/nexus. This was mainly done to facilitate easier upgrades, but it also has the side-effect of making it very easy to backup a Nexus installation.

The Simple Answer

Nexus doesn't store repositories in a database or do anything that would preclude a simple backup of the file system under sonatype-work/nexus. If you need to create a complete backup, just archive the contents of the sonatype-work/nexus.

Better Answer

If you want a more intelligent approach to backing up a Nexus installation, you will certainly want to backup everything under sonatype-work/nexus/conf, sonatype-work/nexus/storage, sonatype-work/nexus/template-store. If you want to backup the metadata and file attributes that Nexus keeps for proxy repository, backup sonatype-work/nexus/proxy, although this isn't required as the information about the proxy repository will be generated on-demand as attributes are requested.

You don't need to backup sonatype-work/nexus/logs and you don't need to backup the Lucene indexes in sonatype-work/nexus/indexer.

Nexus Pro Answer

There is a Nexus Professional plugin which can automate the process of creating a backup of the Nexus configuration data. This plugin is going to address the contents of the sonatype-work/nexus/conf directory. If you need to backup the sonatype-work/nexus/storage directory, you will need to configure some backup system to backup the contents of that filesystem. Once again, as with Nexus Open Source, there is currently no real benefit in backing up the contents of sonatype-work/nexus/indexer or sonatype-work/nexus/logs.

Excluding Storage for Remote Repositories

In your question you mention that you want to exclude the storage devoted to the local cache of a remote repository. If you are interested in doing this, you'll have to take a further level of granularity and just exclude the directories under sonatype-work/nexus/storage that correspond to the remote repositories.

Do you need to shut Nexus down for a backup?

Brian Fox told me no, the only real chance for file contention is going to be the files in the indexer/ directory. You shouldn't have a problem backing up the sonatype-work filesystem with a running instance of Nexus.

BTW, thanks for the question, this answer will likely be incorporated into the next version of the Nexus book.

like image 85
Tim O'Brien Avatar answered Sep 20 '22 11:09

Tim O'Brien