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

.. 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>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>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="transition-from-anaconda-server-sync-conda-to-anaconda-mirror">
    <h2>Transition from anaconda-server-sync-conda to anaconda-mirror<a class="headerlink" href="#transition-from-anaconda-server-sync-conda-to-anaconda-mirror" title="Permalink to this headline">¶</a></h2>
    <p>Please <a class="reference internal" href="mirror-transition.html#mirrors-transition"><span>read our guide</span></a> to transition from the previous to the new tool.</p>
    </div>
    <div class="section" id="the-mirror-command">
    <h2>The mirror command<a class="headerlink" href="#the-mirror-command" 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-mirror</span></code> command:</p>
    <div class="highlight-python"><div class="highlight"><pre><span></span>anaconda-mirror sync
    </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://&lt;your.anaconda.repo&gt;/anaconda/</span></code></p>
    <p>NOTE: Replace <code class="docutils literal"><span class="pre">&lt;your.anaconda.repo&gt;</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>
    <div class="highlight-python"><div class="highlight"><pre><span></span>anaconda-mirror --config-file anaconda-custom sync
    </pre></div>
    </div>
    <p>You can use the &#8220;&#8211;reset&#8221; option to reset the previously mirrored packages:</p>
    <div class="highlight-python"><div class="highlight"><pre><span></span>anaconda-mirror --config-file anaconda-custom sync --reset
    </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>
    <p>If necessary, refer to more information on <a class="reference internal" href="mirrors-sync-configuration.html"><em>whitelist, blacklist and license_blacklist functionality</em></a>.</p>
    <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-python"><div class="highlight"><pre><span></span>anaconda-mirror export mirror.tar
    </pre></div>
    </div>
    <p>This will dump the packages, according to the <a class="reference internal" href="mirrors-sync-configuration.html"><em>configured settings</em></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-python"><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-python"><div class="highlight"><pre><span></span>anaconda-mirror clean --dry-run
    </pre></div>
    </div>
    <p>To remove these packages from your mirror, run the command:</p>
    <div class="highlight-python"><div class="highlight"><pre><span></span>anaconda-mirror clean
    </pre></div>
    </div>
    </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-python"><div class="highlight"><pre><span></span>channels:
        - http://&lt;anaconda.repo.ipaddress&gt;:&lt;port&gt;/conda/anaconda/
    </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>bundled installers</span></a> documentation.</p>
    </div>
