n3dr

Nexus3 backup and recovery tool

This project is maintained by 030

n3dr

Backup or Migrate your entire Nexus Artifact Server

Download all artifacts at once or migrate automatically from Nexus to Nexus.

Without n3dr it is not possible to download all artifacts from Nexus at once. n3dr makes it possible to easily migrate a Nexus server from AWS to Azure or Google Cloud.

GoDoc Widget Build Status Go Report Card StackOverflow SE Questions DevOps SE Questions ServerFault SE Questions Issues Pull requests Total downloads GitHub forks GitHub watchers GitHub stars License Repository Size Contributors Commit activity Last commit Release date Latest Production Release Version Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities CII Best Practices codecov BCH compliance GolangCI Chocolatey n3dr

The aims of the n3dr tool are:

Installation

Linux

snap install n3dr

Note: one has to run n3dr from the home folder if this installation mode is chosen. Otherwise a permission denied issue could occur, while creating the backup zip.

MacOSX

Get the darwin artifact from the releases tab.

Windows

choco install n3dr

Configuration

N3DR download user

Create a user, e.g. n3dr-download in Nexus3, create a role, e.g. n3dr-download and assign the following roles:

N3DR upload user

In order to upload artifacts, additional privileges are required:

Usage

Check the help menu

user@computer:~/dev$ n3dr -h
N3DR is a tool that is able to download all artifacts from
a certain Nexus3 repository.

Usage:
  n3dr [command]

Available Commands:
  backup       Backup all artifacts from a Nexus3 repository
  help         Help about any command
  repositories Count the number of repositories or return their names
  upload       Upload all artifacts to a specific Nexus3 repository

Flags:
  -v, --apiVersion string        The Nexus3 APIVersion, e.g. v1 or beta (default "v1")
  -d, --debug                    Enable debug logging
  -h, --help                     help for n3dr
      --insecureSkipVerify       Skip repository certificate check
  -p, --n3drPass string          The Nexus3 password
  -n, --n3drURL string           The Nexus3 URL
  -u, --n3drUser string          The Nexus3 user
  -z, --zip                      Add downloaded artifacts to a ZIP archive
      --directory-prefix string  The directory prefix is the directory where artifacts will be saved    

Use "n3dr [command] --help" for more information about a command.

Anonymous

In order to download as a anonymous user, one has to use the --anonymous option.

Store the password in a read-only file

Define the password in ~/.n3dr/config.yml:

---
n3drPass: admin123

and set the permissions to read-write by issuing:

chmod 0600 ~/.n3dr/config.yml

Note: other variables like n3drURL and n3drUser could also be added to the config file and one could use --config to overwrite the default config path.

Backup artifacts from a certain repository

All artifacts from a repository will be stored in a download folder when the following command is run:

n3dr backup -u admin -n http://localhost:8081 -r maven-releases

Backup artifacts from a repositories list

All artifacts from a repositories list will be stored in a download folder when the following command is run:

n3dr backup -u admin -n http://localhost:8081 -r maven-releases,maven-private

Backup all repositories

All artifacts from various repositories will be stored in a download folder when the following command is issued:

n3dr repositories -u admin -n http://localhost:8081 -b

Note: a new folder will be created for every repository:

Backup only certain artifacts

It is possible to only download artifacts that match a regular expression. If one would like to download all artifacts from ‘some/group42’ then one could do that as follows:

n3dr backup -u admin -n http://localhost:8081 -r maven-releases -x 'some/group42'

If one would like to deploy is while download from all repositories then use the -x option as well:

n3dr repositories -u admin -n http://localhost:8081 -b -x 'some/group42'

Add all downloaded archives to a ZIP archive

In order to add all archives to a zip archive, one has to use the –zip or -z flag.

If one would like to overwrite the default zip file name, then one has to use the -i option. Note: the extension ‘.zip’ is obliged.

Upload all artifacts to a certain repository

It is possible to upload all JARs that reside in a folder by running the following command:

n3dr upload -u admin -n http://localhost:8081 -r maven-public

“Clone” a Nexus3 repository

Suppose that one has created a new Nexus3 repository, e.g. NexusNEW and that one would like to copy the content of the old repository, e.g. NexusOLD, then these basic steps could be issued to “clone” NexusOLD:

n3dr backup -u <old-nexus3-user> -n <old-nexus3-server-url> \
-r <old-repo-source-name>
cd download
mv <old-repo-source-name> <new-repo-target-name>
n3dr upload -u <new-target-nexus3-user> -n <new-target-nexus3-server-url> \
-r <new-repo-target-name>

Backup to OCI Object Storage

n3dr supports backing up to OCI Object Storage. To enable this option you need to

If you want to remove local copies (after object has been uploaded) add following to ~/.n3dr/config.yml:

removeLocalFile: true

Rationale for N3DR

Although there is a number of equivalent tools:

None of them seems to be able to backup all repositories by running a single command.

Stargazers over time

Stargazers over time