===========================================
Mirroring an Anaconda repository (AER 2.32)
===========================================

.. raw:: html

    <p>NOTE: This documentation is for versions of Anaconda Repository 2.26 and newer. For versions between 2.3.0 and 2.26,
    see <a class="reference internal" href="../../2.23/admin/mirrors-anaconda-repository.html#mirrors-anaconda-repository-2-23"><span class="std std-ref">2.23 documentation</span></a>.
    For documentation of older versions, please see <a class="reference internal" href="../../2.23/admin/mirrors-sync-configuration-2.2.html#mirrors-sync-configuration-2-2"><span class="std std-ref">2.2 documentation</span></a>.</p>
    <div class="section" id="before-you-begin">
    <h2>Before you begin<a class="headerlink" href="#before-you-begin" title="Permalink to this headline">¶</a></h2>
    <p>You need to have already completed <a class="reference external" href="install.html">installing and configuring your Anaconda Repository instance</a>.
    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 <a class="reference external" href="install.html#configure-the-server">instructions for setting the file storage location</a>.</p>
    <p>The full Anaconda mirror requires approximately 90GB.</p>
    </div>
    <div class="section" id="mirroring">
    <h2>Mirroring<a class="headerlink" href="#mirroring" title="Permalink to this headline">¶</a></h2>
    <p>You can mirror some or all of the contents of the <a class="reference external" href="http://docs.continuum.io/anaconda/pkg-docs.html">Anaconda repository</a> using the <code class="docutils literal"><span class="pre">anaconda-server-sync-conda</span></code> command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">server</span><span class="o">-</span><span class="n">sync</span><span class="o">-</span><span class="n">conda</span>
    </pre></div>
    </div>
    <p>This will mirror all of the packages from the Anaconda repository into the <cite>anaconda</cite> user account.</p>
    <p>Verify by opening your browser to <code class="docutils literal"><span class="pre">http://your.anaconda.repo/anaconda/</span></code></p>
    <p>NOTE: Replace <code class="docutils literal"><span class="pre">your.anaconda.repo</span></code> with the actual URL to your installation of Anaconda Repository.</p>
    <p>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
    <code class="docutils literal"><span class="pre">$PREFIX/etc/anaconda-server/mirror/anaconda.yaml</span></code> to <code class="docutils literal"><span class="pre">$PREFIX/etc/anaconda-server/mirror/anaconda-custom.yaml</span></code>.</p>
    <p>For Anaconda Repository 2.27 or newer, there are sample <cite>yaml</cite> config files
    located here: <cite>$PREFIX/etc/anaconda-server/mirror</cite>. <cite>PREFIX</cite> is the install
    location of Anaconda Repository, which by default is at
    <cite>~anaconda-server/repo/etc/anaconda-server/mirror</cite>.</p>
    <p>This command mirrors the repository according to the settings in the
    configuration file <code class="docutils literal"><span class="pre">anaconda-custom.yaml</span></code>:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">server</span><span class="o">-</span><span class="n">sync</span><span class="o">-</span><span class="n">conda</span> <span class="o">--</span><span class="n">mirror</span><span class="o">-</span><span class="n">config</span> <span class="n">anaconda</span><span class="o">-</span><span class="n">custom</span>
    </pre></div>
    </div>
    <p>If necessary, refer to more information on <a class="reference internal" href="mirrors-sync-configuration.html"><span class="doc">whitelist, blacklist and license_blacklist functionality</span></a>.</p>
    </div>
    <div class="section" id="deprecated-anaconda-mirror-command">
    <h2>Deprecated <code class="docutils literal"><span class="pre">anaconda-mirror</span></code> command<a class="headerlink" href="#deprecated-anaconda-mirror-command" title="Permalink to this headline">¶</a></h2>
    <p>The <code class="docutils literal"><span class="pre">anaconda-mirror</span></code> command is deprecated but still in use at some
    installations.</p>
    <p>It is used with the command <code class="docutils literal"><span class="pre">anaconda-mirror</span> <span class="pre">sync</span></code>, or with a configuration
    file such as <code class="docutils literal"><span class="pre">anaconda-custom.yaml</span></code> with the command
    <code class="docutils literal"><span class="pre">anaconda-mirror</span> <span class="pre">--config-file</span> <span class="pre">anaconda-custom</span> <span class="pre">sync</span></code>.</p>
    <div class="section" id="resetting-packages">
    <h3>Resetting packages<a class="headerlink" href="#resetting-packages" title="Permalink to this headline">¶</a></h3>
    <p>You can use the &#8220;&#8211;reset&#8221; option to reset the previously mirrored packages:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">mirror</span> <span class="o">--</span><span class="n">config</span><span class="o">-</span><span class="n">file</span> <span class="n">anaconda</span><span class="o">-</span><span class="n">custom</span> <span class="n">sync</span> <span class="o">--</span><span class="n">reset</span>
    </pre></div>
    </div>
    <p>This resets the &#8220;last sync&#8221; time for the repository, so <code class="docutils literal"><span class="pre">anaconda-mirror</span></code>
    requests all packages, not just those changed or added since the last sync. As
    the requests are processed, <code class="docutils literal"><span class="pre">anaconda-mirror</span></code> still automatically downloads
    only those files that differ from the files currently in the repository.</p>
    </div>
    <div class="section" id="exporting-a-mirror">
    <h3>Exporting a mirror<a class="headerlink" href="#exporting-a-mirror" title="Permalink to this headline">¶</a></h3>
    <p>Generate a mirror archive with this command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">mirror</span> <span class="n">export</span> <span class="n">mirror</span><span class="o">.</span><span class="n">tar</span>
    </pre></div>
    </div>
    <p>This will dump the packages, according to the <a class="reference internal" href="mirrors-sync-configuration.html"><span class="doc">configured settings</span></a>, into the file <code class="docutils literal"><span class="pre">mirror.tar</span></code>.</p>
    <p>This mirror can be used in an air-gapped environment.</p>
    </div>
    <div class="section" id="importing-a-mirror">
    <h3>Importing a mirror<a class="headerlink" href="#importing-a-mirror" title="Permalink to this headline">¶</a></h3>
    <p>To mirror the Anaconda repository in an air-gapped environment, using a system with no internet access,
    point <code class="docutils literal"><span class="pre">anaconda-mirror</span></code> to the exported mirror archive.</p>
    <p>Mount the USB drive and then run the following command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>anaconda-mirror import $USB/mirror.tar
    </pre></div>
    </div>
    <p>This will mirror the contents of the local Anaconda repository to your Anaconda Repository installation under the username <code class="docutils literal"><span class="pre">anaconda</span></code>.</p>
    </div>
    <div class="section" id="filtering">
    <h3>Filtering<a class="headerlink" href="#filtering" title="Permalink to this headline">¶</a></h3>
    <p>If you wish to update the filters on your mirror (for example, to exclude additional licenses), running <code class="docutils literal"><span class="pre">anaconda-mirror</span> <span class="pre">sync</span></code> again
    will retrieve new packages that match this filter, but it will not remove existing packages that no longer match the filter.</p>
    <p>To see which packages no longer match your filter, run the command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">mirror</span> <span class="n">clean</span> <span class="o">--</span><span class="n">dry</span><span class="o">-</span><span class="n">run</span>
    </pre></div>
    </div>
    <p>To remove these packages from your mirror, run the command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">anaconda</span><span class="o">-</span><span class="n">mirror</span> <span class="n">clean</span>
    </pre></div>
    </div>
    </div>
    </div>
    <div class="section" id="mirror-additional-channels">
    <span id="mirror-other-channels"></span><h2>Mirror additional channels<a class="headerlink" href="#mirror-additional-channels" title="Permalink to this headline">¶</a></h2>
    <p>If mirroring from an <strong>air gap archive</strong>, the channel in the following
    configuration points to a local directory to which the archive is expanded.</p>
    <p>In addition, if a platform specific archive is downloaded, then the config file
    needs the platforms section. The examples in the following sections assume
    <cite>x64-repo-mirrors-*.tar &lt;airgap-archive-mirrors&gt;</cite> is expanded to
    <cite>$MIRRORS_ARCHIVE</cite>.</p>
    <p>Similarly, for an <strong>online system</strong>, the channel points to Anaconda Cloud. The
    platforms are optional and will limit the mirrored conda packages to specified
    platforms.</p>
    <div class="section" id="mirror-r-channel">
    <h3>Mirror R channel<a class="headerlink" href="#mirror-r-channel" title="Permalink to this headline">¶</a></h3>
    <ol class="arabic">
    <li><p class="first">Create yaml config.</p>
    <p>Here&#8217;s an example config to mirror from an air gap archive containing only
    <cite>x64</cite> packages:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ 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
    </pre></div>
    </div>
    <p>Here&#8217;s an example for an online system:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ cat $PREFIX/etc/anaconda-server/mirror/r.yaml

    channels:
      - https://conda.anaconda.org/r
    </pre></div>
    </div>
    </li>
    <li><p class="first">Mirror the packages to <cite>r-channel</cite>:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>anaconda-server-sync-conda --mirror-config \
        $PREFIX/etc/anaconda-server/mirror/r.yaml --account=r-channel
    </pre></div>
    </div>
    </li>
    </ol>
    </div>
    <div class="section" id="mirror-wakari-channel-for-ae-n">
    <h3>Mirror wakari channel for AE-N<a class="headerlink" href="#mirror-wakari-channel-for-ae-n" title="Permalink to this headline">¶</a></h3>
    <ol class="arabic">
    <li><p class="first">Create yaml config.</p>
    <p>Here&#8217;s an example config to mirror from an air gap archive containing only
    <cite>x64</cite> packages:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ 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
    </pre></div>
    </div>
    <p>Here&#8217;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:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ cat $PREFIX/etc/anaconda-server/mirror/wakari.yaml

    channels:
      - https://conda.anaconda.org/t/&lt;TOKEN&gt;/anaconda-nb-extensions
      - https://conda.anaconda.org/wakari
    </pre></div>
    </div>
    </li>
    <li><p class="first">Mirror the packages to <cite>wakari</cite> channel:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>anaconda-server-sync-conda --mirror-config \
        $PREFIX/etc/anaconda-server/mirror/wakari.yaml --account=wakari
    </pre></div>
    </div>
    </li>
    </ol>
    </div>
    <div class="section" id="mirror-anaconda-adam-channel-for-cluster-management">
    <h3>Mirror anaconda-adam channel for cluster management<a class="headerlink" href="#mirror-anaconda-adam-channel-for-cluster-management" title="Permalink to this headline">¶</a></h3>
    <ol class="arabic">
    <li><p class="first">Create yaml config.</p>
    <p>Here&#8217;s an example config to mirror from an air gap archive containing only
    <cite>x64</cite> packages:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ 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
    </pre></div>
    </div>
    <p>Here&#8217;s an example for an online system:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ cat $PREFIX/etc/anaconda-server/mirror/anaconda-adam.yaml

    channels:
      - https://conda.anaconda.org/anaconda-adam
    </pre></div>
    </div>
    </li>
    <li><p class="first">Mirror the packages to <cite>anaconda-adam</cite> channel:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>anaconda-server-sync-conda --mirror-config \
        $PREFIX/etc/anaconda-server/mirror/anaconda-adam.yaml --account=anaconda-adam
    </pre></div>
    </div>
    </li>
    </ol>
    </div>
    </div>
    <div class="section" id="configure-conda">
    <h2>Configure conda<a class="headerlink" href="#configure-conda" title="Permalink to this headline">¶</a></h2>
    <p>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 <cite>~/.condarc</cite> file to add the appropriate channel:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">channels</span><span class="p">:</span>
        <span class="o">-</span> <span class="n">http</span><span class="p">:</span><span class="o">//&lt;</span><span class="n">anaconda</span><span class="o">.</span><span class="n">repo</span><span class="o">.</span><span class="n">ipaddress</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">port</span><span class="o">&gt;/</span><span class="n">conda</span><span class="o">/</span><span class="n">anaconda</span><span class="o">/</span>
    </pre></div>
    </div>
    <p>NOTE: Replace &lt;anaconda.repo.ipaddress&gt; with the actual URL to your installation of Anaconda Repository.</p>
    <p>NOTE: This configuration change can be made at the user level or via an <a class="reference external" href="http://conda.pydata.org/docs/admin.html">administrative</a> conda file, to force all internal users to use your local Anaconda mirror rather than querying the Anaconda repository.</p>
    <p>NOTE: Users can download Anaconda installers that are pre-configured to search your Repository from <code class="docutils literal"><span class="pre">http://&lt;anaconda.repository.addr&gt;/downloads</span></code>. To
    learn how to generate these installers, see the <a class="reference internal" href="custom-anaconda-installers.html#bundled-installers"><span class="std std-ref">bundled installers</span></a> documentation.</p>
    </div>
