# Migrate from Sonatype Nexus 3 to CloudRepo

Moving from Sonatype Nexus to CloudRepo takes three steps: create the repositories in CloudRepo, copy the files, and point your builds at the new URLs. On a Nexus 3 server, one command does the copy, `cloudrepo-migrate nexus3`, and it checks what it moves. For a Nexus 2 server, use `cloudrepo-migrate nexus2` in the [Nexus 2 section](#nexus-2-servers).

Install it with one line, on a machine that can reach your Nexus 3 server:

```sh
pipx install cloudrepo-migrate
```

That installs the tool from pypi.org and puts `cloudrepo-migrate` on your PATH. Without pipx, run `pip install cloudrepo-migrate` in a virtual environment on the machine that reaches your Nexus 3 server. It needs Python 3.8 or later and has no dependencies. The docs guide, [Migrate from Nexus 3 to CloudRepo](/docs/migrate/from-nexus-3.html), covers the same command.

## What the command moves

| Nexus 3 repository                                                             | What the tool does                                                                     |
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| Nexus 3 hosted Maven repository                                                | Copies every file, POMs and checksum files included                                    |
| Nexus 3 hosted npm repository                                                  | Copies every version of each package, oldest first, with its dist-tags                 |
| Nexus 3 hosted Python repository                                               | Copies every wheel and sdist, each under the project name its own metadata gives       |
| Nexus 3 hosted Docker repository                                               | Copies every tag of every image, from version 0.6.0, with its manifest and every layer |
| Nexus 3 proxy or group repository                                              | Skips it and says why in the report                                                    |
| Any other format                                                               | Skips it and says why in the report                                                    |
| Files Nexus makes itself (`.index`, `.meta`, the root `archetype-catalog.xml`) | Skips them                                                                             |

Every Maven, npm and Python file is read back from CloudRepo and its sha1 and sha256 compared with the bytes Nexus served. A checksum file Nexus holds (`X.sha1`, `X.md5` and the rest) must name the digest of `X`. Any mismatch fails the run and the report names the file.

A Docker layer must hash to the digest its manifest names before it uploads, and each manifest is read back by digest. Layers are not read back. Version 0.6.0 of `cloudrepo-migrate` is tested on Nexus 3.76.0 with hosted Maven, npm, Python and Docker repositories.

## Step 1: Create the repositories in CloudRepo

[Start free trial](/signup). 14 days free. No credit card required. Then create each target repository in the portal with the same name and the same format as its Nexus repository. A different name is fine: map it with `--repo SOURCE=TARGET`. Then create a repository token that can write to those repositories.

## Step 2: Do a dry run

Put the credentials in the environment: `NEXUS_USERNAME` and `NEXUS_PASSWORD` (leave both unset for anonymous read) and `CLOUDREPO_TOKEN`. Set them in your shell, never on the command line: there is no flag for them, and on a terminal the tool asks for any that are missing.

```sh
cloudrepo-migrate nexus3 \
  --nexus-url https://nexus.example.com \
  --org acme --dry-run
```

`--nexus-url` is the base URL of your server, with no `/nexus` on a default Nexus 3 install. A dry run lists what would move and uploads nothing. With the token set, it also checks the token and that every target repository exists.

## Step 3: Copy the files

```sh
cloudrepo-migrate nexus3 \
  --nexus-url https://nexus.example.com \
  --org acme --report-json report.json
```

| Exit code | Meaning                                                                           |
| --------- | --------------------------------------------------------------------------------- |
| `0`       | Everything moved and was verified                                                 |
| `1`       | At least one file failed; each is listed with its path. Run it again to resume.   |
| `2`       | A usage or preflight problem, such as a missing target repository. Nothing moved. |

To resume, run the same command again. A file CloudRepo already holds with the same bytes is counted as present and not uploaded twice.

| Flag                     | Use it for                                              |
| ------------------------ | ------------------------------------------------------- |
| `--repo SOURCE[=TARGET]` | Move only these repositories (repeat the flag)          |
| `--jobs N`               | Parallel Maven and Python uploads (default 4)           |
| `--nexus-ca-file PEM`    | A Nexus server with a private certificate               |
| `--work-dir DIR`         | Where each file waits while it moves (default `TMPDIR`) |

## Step 4: Point your builds at CloudRepo

Each repository is at `https://acme.mycloudrepo.io/repositories/NAME`, with your organization in place of `acme`. The docs show the lines to change for [Maven](/docs/formats/maven.html), [Gradle](/docs/consume/gradle.html), [npm](/docs/formats/npm.html), [Python](/docs/consume/python.html) and [Docker](/docs/consume/docker.html).

Switch one build at a time and keep the Nexus server up until every build has passed against CloudRepo. Proxy repositories are not copied, because they only hold cached copies of public packages. For a Maven proxy, [create a CloudRepo proxy](/docs/consume/proxy-repositories.html) in its place.

## Nexus 2 servers

A Nexus 2 server has its own command, `cloudrepo-migrate nexus2`, with the same steps, flags and exit codes. On Nexus 2, `cloudrepo-migrate nexus2` moves the hosted Maven and npm repositories the same way. A proxy, a group or any other format is skipped, and the report says why.

```sh
cloudrepo-migrate nexus2 \
  --nexus-url https://nexus.example.com/nexus \
  --org acme --dry-run
```

Its `--nexus-url` ends in `/nexus` on a default install. Run the same command without `--dry-run` to copy the files. The [Nexus 2 migration guide](/docs/migrate/from-nexus-2.html) has the steps.

## Other formats

For a format the tool does not move, the [Nexus migration page in the docs](/docs/migrate/from-nexus.html) covers exporting the files and uploading them by hand.

CloudRepo hosts Maven, npm, Python (PyPI) and Docker/OCI repositories, and plans start at $99/month billed annually. The [Nexus comparison](/nexus-alternative) sets the two side by side.

---

The page: https://www.cloudrepo.io/articles/migrate-from-nexus-to-cloudrepo
