# Move yum repositories from Artifactory or Nexus to CloudRepo

> Map your Artifactory or Nexus yum repositories to CloudRepo, upload the RPMs you build, and repoint dnf and zypper.

The RPMs your team builds move into a hosted yum repository in CloudRepo, and each remote repository becomes a yum proxy. dnf and zypper then install from your organization’s CloudRepo host. Your old server is only read. It keeps running, unchanged, until you repoint your machines.

> **Early access:** Hosted yum repositories and yum proxy repositories are in early access.

## What maps to what

| In Artifactory         | In Nexus 3            | In CloudRepo                                                                                                       |
| ---------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| Local RPM repository   | Hosted yum repository | A hosted yum repository. You upload your RPMs to it.                                                               |
| Remote RPM repository  | Proxy yum repository  | A yum proxy of openSUSE, Rocky Linux, EPEL or PostgreSQL. Nothing to move: it reads the distribution’s repository. |
| Virtual RPM repository | Group yum repository  | CloudRepo has no yum group. Point each machine at the hosted repository and at each proxy.                         |

One yum proxy reads one repository. A Nexus proxy whose URL holds `$releasever` and `$basearch` serves every release of a mirror, so make one CloudRepo proxy for each repository your machines read. The other Artifactory and Nexus terms are on [Artifactory and Nexus terms in CloudRepo](/docs/migrate/artifactory-and-nexus-terms.html).

CloudRepo signs each hosted repository’s index with your organization’s key, and never your packages: each RPM stays exactly as your build made it, so a package you signed keeps its signature. Your machines trust the new key once, as the setup below shows.

## 1. Create your repositories

Create a hosted yum repository as [Host your own RPMs](/docs/consume/yum-hosted.html#create-a-hosted-yum-repository) shows, and a yum proxy for each remote repository as [Pull Linux packages](/docs/consume/yum.html#create-a-yum-proxy) shows. You also need a repository token that can write to the hosted repository.

## 2. Export your RPMs

The tool can do steps 2 and 3 for you. `cloudrepo-migrate` reads each binary RPM from your hosted yum repository, uploads it to your hosted yum repository in CloudRepo, and reads it back to check it. It leaves the old `repodata` where it is, since CloudRepo builds and signs its own index. yum is off unless you add `--include yum`, from version 0.13.0: a run without it skips each yum repository and says so. Install the tool and set your credentials as [Nexus 3](/docs/migrate/from-nexus-3.html#1-install-the-tool) or [Artifactory](/docs/migrate/from-artifactory.html#1-install-the-tool) shows. Name your hosted repository as your old one is named, or map the two with `--repo SOURCE=TARGET`.

On Nexus 3, a dry run lists what would move and what it skips, and uploads nothing:

**Terminal**

```bash
cloudrepo-migrate nexus3 \
  --nexus-url https://nexus.example.com \
  --org your-org \
  --include yum \
  --dry-run
```

On Artifactory, the same flag moves a local RPM repository. It is experimental: it is tested against a stand-in for Artifactory’s API, not yet against a real Artifactory server.

**Terminal**

```bash
cloudrepo-migrate artifactory \
  --artifactory-url https://artifactory.example.com/artifactory \
  --org your-org \
  --include yum \
  --dry-run
```

When the list looks right, run the same command without `--dry-run` and go to step 4. Nexus 2 has no yum move. To move by hand, or from Nexus 2, export each local or hosted RPM repository. A remote, proxy, virtual or group repository has nothing to export.

- **Artifactory.** Run the loop in step 3 of [Migrate from JFrog Artifactory](/docs/migrate/from-jfrog.html#3-export-the-files), with `REPO` set to the key of your local RPM repository. It saves every file under `export/<repository>/`, the `repodata` folder [Artifactory creates](https://docs.jfrog.com/artifactory/docs/rpm-repositories) included.
- **Nexus 3.** Run the loop in step 3 of [Migrate from Sonatype Nexus Repository](/docs/migrate/from-nexus.html#3-export-the-files), with `REPO` set to the name of your hosted yum repository. It saves every asset the [assets API](https://help.sonatype.com/en/assets-api.html) lists under `export/<repository>/`.
- **Nexus 2.** List your RPMs with your server’s API, as [Sonatype’s Nexus Repository 2 help](https://help.sonatype.com/en/repository-manager-2.html) shows, and download each `.rpm`.

Only the `.rpm` files move. Leave the old `repodata`: CloudRepo builds and signs its own index from the RPMs you upload.

## 3. Upload them to CloudRepo

First make a login file that only you can read:

**Terminal**

```bash
install -m 600 /dev/null ~/.cloudrepo.netrc
```

Save your login in it:

`~/.cloudrepo.netrc`

```ini
machine your-org.mycloudrepo.io login you@example.com password YOUR_REPOSITORY_TOKEN
```

This line uploads one RPM:

**Terminal**

```bash
curl --netrc-file ~/.cloudrepo.netrc --fail -T acme-agent-1.4.2-1.x86_64.rpm https://your-org.mycloudrepo.io/repositories/your-repo/
```

To upload every RPM you exported, run the same line for each one. Put your repository’s key or name in place of `rpm-local`:

**Terminal**

```bash
find export/rpm-local -name '*.rpm' | while IFS= read -r rpm; do
  curl --netrc-file ~/.cloudrepo.netrc --fail -T "$rpm" https://your-org.mycloudrepo.io/repositories/your-repo/ || echo "FAILED: $rpm" >&2
done
```

CloudRepo files each package by its own name, version and architecture, whatever the file is called. A package can be up to 2 GiB. You can run the loop again after a failure: an RPM CloudRepo already holds with the same bytes is answered as already stored, and a different RPM under a name and version it already holds is refused with `409`.

## 4. Repoint your machines

Each old address, as Sonatype’s and JFrog’s examples write it, and the address that replaces it:

| baseurl in Nexus or Artifactory                                              | baseurl on CloudRepo                                     |
| ---------------------------------------------------------------------------- | -------------------------------------------------------- |
| `http://<serveraddress:port>/repository/yum-proxy/$releasever/os/$basearch/` | `https://your-org.mycloudrepo.io/repositories/your-repo` |
| `http://localhost:8081/artifactory/targetCentos/`                            | `https://your-org.mycloudrepo.io/repositories/your-repo` |

The Nexus form is from [Sonatype’s yum page](https://help.sonatype.com/en/yum-repositories.html) and the Artifactory form from [JFrog’s RPM page](https://docs.jfrog.com/artifactory/docs/rpm-repositories). Put the CloudRepo repository that replaces each old one in place of `your-repo`.

Then write each machine’s repository file as CloudRepo’s pages show: for the hosted repository, [Set up dnf](/docs/consume/yum-hosted.html#set-up-dnf) or [Set up zypper](/docs/consume/yum-hosted.html#set-up-zypper), which name its signing key; for a proxy, [Pull Linux packages with zypper and dnf](/docs/consume/yum.html). Remove the old server’s repository file, or set `enabled=0` in it, so the machine reads CloudRepo alone. A build image or a Dockerfile that writes a repository file needs the same change, and [Beyond the files](/docs/migrate/repoint-builds.html#beyond-the-files) lists the other places to look.

## 5. Check the move

On a machine that reads only CloudRepo, install one of your own packages. Put its name in place of `acme-agent`. With dnf:

**Terminal**

```bash
sudo dnf install -y acme-agent
```

With zypper:

**Terminal**

```bash
sudo zypper -n install acme-agent
```

dnf and zypper check the signed index on the way. Leave the old server running until every machine installs this way.

---

The page: https://www.cloudrepo.io/docs/migrate/yum.html
