Anaconda Enterprise: Documentation

# Mirroring an Anaconda repository (AER 2.32)

NOTE: This documentation is for versions of Anaconda Repository 2.26 and newer. For versions between 2.3.0 and 2.26, see 2.23 documentation. For documentation of older versions, please see 2.2 documentation.

## Before you begin

You need to have already completed installing and configuring your Anaconda Repository instance. Due to the size of the Anaconda Repository, it is important that you have configured a file storage location with sufficient disk space. If necessary please see the instructions for setting the file storage location.

The full Anaconda mirror requires approximately 90GB.

## Mirroring

You can mirror some or all of the contents of the Anaconda repository using the `anaconda-server-sync-conda` command:

    anaconda-server-sync-conda

This will mirror all of the packages from the Anaconda repository into the anaconda user account.

Verify by opening your browser to `http://your.anaconda.repo/anaconda/`

NOTE: Replace `your.anaconda.repo` with the actual URL to your installation of Anaconda Repository.

Alternately, you may not wish to mirror all packages. To mirror a subset of the total repository, specify which platforms you want to include, or use the whitelist, blacklist or license_blacklist functionality to control which packages are mirrored by copying the default configuration file `$PREFIX/etc/anaconda-server/mirror/anaconda.yaml` to `$PREFIX/etc/anaconda-server/mirror/anaconda-custom.yaml`.

For Anaconda Repository 2.27 or newer, there are sample yaml config files located here: $PREFIX/etc/anaconda-server/mirror. PREFIX is the install location of Anaconda Repository, which by default is at ~anaconda-server/repo/etc/anaconda-server/mirror.

This command mirrors the repository according to the settings in the configuration file `anaconda-custom.yaml`:

    anaconda-server-sync-conda --mirror-config anaconda-custom

If necessary, refer to more information on whitelist, blacklist and license_blacklist functionality.

## Deprecated `anaconda-mirror` command

The `anaconda-mirror` command is deprecated but still in use at some installations.

It is used with the command `anaconda-mirror sync`, or with a configuration file such as `anaconda-custom.yaml` with the command `anaconda-mirror --config-file anaconda-custom sync`.

### Resetting packages

You can use the “–reset” option to reset the previously mirrored packages:

    anaconda-mirror --config-file anaconda-custom sync --reset

This resets the “last sync” time for the repository, so `anaconda-mirror` requests all packages, not just those changed or added since the last sync. As the requests are processed, `anaconda-mirror` still automatically downloads only those files that differ from the files currently in the repository.

### Exporting a mirror

Generate a mirror archive with this command:

    anaconda-mirror export mirror.tar

This will dump the packages, according to the configured settings, into the file `mirror.tar`.

This mirror can be used in an air-gapped environment.

### Importing a mirror

To mirror the Anaconda repository in an air-gapped environment, using a system with no internet access, point `anaconda-mirror` to the exported mirror archive.

Mount the USB drive and then run the following command:

    anaconda-mirror import $USB/mirror.tar

This will mirror the contents of the local Anaconda repository to your Anaconda Repository installation under the username `anaconda`.

### Filtering

If you wish to update the filters on your mirror (for example, to exclude additional licenses), running `anaconda-mirror sync` again will retrieve new packages that match this filter, but it will not remove existing packages that no longer match the filter.

To see which packages no longer match your filter, run the command:

    anaconda-mirror clean --dry-run

To remove these packages from your mirror, run the command:

    anaconda-mirror clean

## Mirror additional channels

If mirroring from an air gap archive, the channel in the following configuration points to a local directory to which the archive is expanded.

In addition, if a platform specific archive is downloaded, then the config file needs the platforms section. The examples in the following sections assume x64-repo-mirrors-*.tar <airgap-archive-mirrors> is expanded to $MIRRORS_ARCHIVE.

Similarly, for an online system, the channel points to Anaconda Cloud. The platforms are optional and will limit the mirrored conda packages to specified platforms.

### Mirror R channel

1. Create yaml config.

   Here’s an example config to mirror from an air gap archive containing only x64 packages:

       $ cat $PREFIX/etc/anaconda-server/mirror/r.yaml

       channels:
         - file://$MIRRORS_ARCHIVE/r/pkgs

       # The platforms should correspond with the platforms contained in the
       # archive. Omit if the archive contains conda packages for all platforms.
       platforms:
         - linux-64
         - osx-64
         - win-64

   Here’s an example for an online system:

       $ cat $PREFIX/etc/anaconda-server/mirror/r.yaml

       channels:
         - https://conda.anaconda.org/r

2. Mirror the packages to r-channel:

       anaconda-server-sync-conda --mirror-config \
           $PREFIX/etc/anaconda-server/mirror/r.yaml --account=r-channel

### Mirror wakari channel for AE-N

1. Create yaml config.

   Here’s an example config to mirror from an air gap archive containing only x64 packages:

       $ cat $PREFIX/etc/anaconda-server/mirror/wakari.yaml

       channels:
         - file://$MIRRORS_ARCHIVE/wakari/pkgs

       # The platforms should correspond with the platforms contained in the
       # archive. Omit if the archive contains conda packages for all platforms.
       platforms:
         - linux-64
         - osx-64
         - win-64

   Here’s an example for an online system. If applicable, you will have received the TOKEN for the anaconda-nb-extensions channel along with your license:

       $ cat $PREFIX/etc/anaconda-server/mirror/wakari.yaml

       channels:
         - https://conda.anaconda.org/t/<TOKEN>/anaconda-nb-extensions
         - https://conda.anaconda.org/wakari

2. Mirror the packages to wakari channel:

       anaconda-server-sync-conda --mirror-config \
           $PREFIX/etc/anaconda-server/mirror/r.yaml --account=wakari

### Mirror anaconda-adam channel for cluster management

1. Create yaml config.

   Here’s an example config to mirror from an air gap archive containing only x64 packages:

       $ cat $PREFIX/etc/anaconda-server/mirror/anaconda-adam.yaml

       channels:
         - file://$MIRRORS_ARCHIVE/anaconda-adam/pkgs

       # The platforms should correspond with the platforms contained in the
       # archive. Omit if the archive contains conda packages for all platforms.
       platforms:
         - linux-64
         - osx-64
         - win-64

   Here’s an example for an online system:

       $ cat $PREFIX/etc/anaconda-server/mirror/anaconda-adam.yaml

       channels:
         - https://conda.anaconda.org/anaconda-adam

2. Mirror the packages to anaconda-adam channel:

       anaconda-server-sync-conda --mirror-config \
           $PREFIX/etc/anaconda-server/mirror/r.yaml --account=anaconda-adam

## Configure conda

Having created the mirror, you will still need to configure conda to search for packages here rather than on the default Anaconda repository. You can do that by editing your ~/.condarc file to add the appropriate channel:

    channels:
        - http://<anaconda.repo.ipaddress>:<port>/conda/anaconda/

NOTE: Replace <anaconda.repo.ipaddress> with the actual URL to your installation of Anaconda Repository.

NOTE: This configuration change can be made at the user level or via an administrative conda file, to force all internal users to use your local Anaconda mirror rather than querying the Anaconda repository.

NOTE: Users can download Anaconda installers that are pre-configured to search your Repository from `http://<anaconda.repository.addr>/downloads`. To learn how to generate these installers, see the bundled installers documentation.