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

.. raw:: html

    <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 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="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 anaconda-server-sync-conda 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 Anaconda repository into the <cite>anaconda</cite> binstar 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 &lt;your.anaconda.repo&gt; 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:</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="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">binstar</span><span class="o">/</span><span class="n">mirrors</span><span class="o">/</span><span class="n">conda</span><span class="o">.</span><span class="n">yaml</span>
    </pre></div>
    </div>
    <p>If necessary, refer to more information on <a class="reference external" href="mirrors-sync-configuration.html">whitelist, blacklist and license_blacklist functionality</a>.</p>
    <div class="section" id="in-an-air-gapped-environment">
    <h3>In an air-gapped environment:<a class="headerlink" href="#in-an-air-gapped-environment" 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, you create a local copy of the Anaconda Repository using a USB drive provided by Continuum, and point anaconda-server-sync-conda to the extracted tarball.</p>
    <p>First, mount the USB drive and extract the tarball.  In this example we will extract to <cite>/tmp</cite>:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ cd /tmp
    $ tar xvf &lt;path to&gt;/mirror.tar
    </pre></div>
    </div>
    <p>Now you have a local Anaconda Repository located at <cite>/tmp/mirror/pkgs</cite>. This repository can be mirrored. Edit <cite>/etc/binstar/mirrors/conda.yaml</cite> to contain:</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="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">mirror</span><span class="o">/</span><span class="n">pkgs</span>
    </pre></div>
    </div>
    <p>And then run the above command:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span>$ anaconda-server-sync-conda --mirror-config /etc/binstar/mirrors/conda.yaml
    </pre></div>
    </div>
    <p>This will mirror the contents of the local Anaconda Repository to your Anaconda Repository installation under the username &#8216;anaconda.&#8217;</p>
    </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>
    </div>
    <div class="section" id="advanced-mirror-configuration">
    <h2>Advanced mirror configuration<a class="headerlink" href="#advanced-mirror-configuration" title="Permalink to this headline">¶</a></h2>
    <p>These instructions are for OS X and Linux only.</p>
    <p><strong>Point Anaconda repository to multiple mirrors.</strong></p>
    <p>You can create multiple mirrors, with each mirror put into its own account. You must specify the account name when mirroring. If the account does not exist, a mirror account is created and assigned a random password. This allows you to use the GUI to log in, create tokens and manage the mirror.</p>
    <p>sync_conda_mirror.py &#8211;account anaconda &#8211;mirror-config /etc/binstar/mirrors/anaconda.yaml</p>
    <p>Note: If the account doesn&#8217;t exist, Anaconda repo will create the account and a default password.</p>
    <p><strong>Make packages on mirror private.</strong></p>
    <p>Packages may also be set to be private as shown:</p>
    <p>sync_conda_mirror.py &#8211;account private &#8211;mirror-config /etc/binstar/mirrors/private.yaml &#8211;private</p>
    <p>NOTE: Packages must be set to &#8220;private&#8221; when they are first created; you cannot retroactively designate an existing package as private.</p>
    </div>
