Anaconda Enterprise: Documentation

# Mirroring an Anaconda repository (AER 2.27)

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.

## Transition from anaconda-server-sync-conda to anaconda-mirror

Please read our guide to transition from the previous to the new tool.

## The mirror command

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

    anaconda-mirror sync

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`:

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

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.

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

### 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

## 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.