Skip to main content
Mirroring via the CLI can accomplish things that would be cumbersome via the GUI. For general information about mirrors, see Mirrors. Mirrors exist within channels in Package Security Manager. When working in the CLI, you need to create a channel to populate with a mirror or know which channels are already available. Anaconda recommends that channels contain only one mirror each to prevent conflicts between package sources and mirror filters. A channel can contain multiple mirrors, but you need to ensure your mirror filters do not overlap in a conflicting manner.

Creating a mirror

The basic command for creating a mirror is:
This creates an exact copy of the mirrored repository with no restrictions on what gets copied.
To reduce CPU usage while a large mirror runs, you can freeze the channel first with conda repo channel --freeze <CHANNEL_NAME>. Packages don’t appear in a frozen channel, so unfreeze it with conda repo channel --unfreeze <CHANNEL_NAME> when the mirror completes. For more information, see Freezing and unfreezing channels.
Your mirror type must match the source repository. For example, if your source mirror contains conda packages, you must use conda as your mirror type.
You can add arguments to the basic mirror command to further specify configurations, such as restricting available packages or downloading only specific versions. To create a mirror and populate it with a specific set of packages:
For example, to create a mirror called “snakes” in a channel named “lua” and populate it with packages for Mac users only:
Populating your channel with specific packages does not automatically include their dependencies. If you do not have all necessary packages, conda cannot create an environment from the channel.

Creating a mirror with a policy

When you create or edit a mirror on a channel that has a policy, the channel’s policy is automatically applied. To assign a specific policy to the mirror instead, include --use-channel-policy False and --policy-id <POLICY_ID>:
Don’t combine --policy-id with mirror filter arguments such as --only_spec or --subdirs. The command fails with an error. Define those filters in the policy instead.
For more information, see Policies.

Filtering mirrored packages

Policies were introduced in Package Security Manager version 6.7.0. If your version supports policies, use policy filtering for channels that contain conda packages. For all other mirror types (Std Python, R), use the mirror filters described below.
Adding filters to your mirrors ensures you only mirror the packages you need. You can filter by platform, license, specific packages, CVE score, and date range. For more information about CVEs, see Common Vulnerabilities and Exposures (CVEs).
Filters can also be applied at the channel level. Both the channel filter and the mirror filter are applied. The mirror filter restricts packages pulled from the source mirror, and the channel filter restricts which packages are allowed into the channel. Filters should not contain configurations that conflict with one another.

Platform filtering

--subdirs: Instruct Package Security Manager to only mirror packages for the provided subdirectories. Anaconda recommends you always include the noarch platform as well as the specific platform architectures necessary for your organization. Use a comma-separated string in double quotes:
Available platforms: noarch, linux-32, linux-64, linux-aarch64, linux-armv6l, linux-armv7l, linux-ppc64, linux-ppc64le, osx-64, osx-arm64, win-32, win-64, zos-z
If your source mirror does not contain conda packages, this argument is not necessary.

Mirror type

--type: Denotes the mirror type. Possible types are conda, python_simple, and CRAN:

PyPI project filtering

--projects: List of PyPI projects to mirror. Use a comma-separated string in double quotes:

License filtering

--licenses: Include or exclude licenses. To exclude a license, prepend the entry with a hyphen (-). Use a comma-separated string in double quotes:
Available licenses: agpl, gpl2, gpl3, lgpl, bsd, mit, apache, psf, public_domain, proprietary, other, none

Package filtering

--only_spec: Include a specific package from the source mirror. Uses MatchSpec to specify the package. Supply this argument multiple times for multiple entries.
For more information about MatchSpec queries, see Package match specifications.
--exclude_spec: Exclude a package from the source mirror. Supply this argument multiple times for multiple entries:
--include_spec: Include a package (or a specific version) that would otherwise be excluded by --exclude_spec. Supply this argument multiple times for multiple entries:

CVE filtering

--cve_score: Remove all files associated with a CVE that has a score equal to or higher than the threshold value. CVE scores range from 0–10 and can contain up to one decimal point:
--exclude_uncurated_cve_packages: Remove all files associated with uncurated CVEs. This argument takes no value:
Package Security Manager 6.8.0 doesn’t support --exclude_uncurated_cve_packages for conda mirrors. The mirror is created, but the filter is ignored. To exclude uncurated CVE packages, use the --exclude-uncurated-cve-packages option in a policy.

Date filtering

--date_from: Start of a date range for when a conda package was published. Format: YYYY-MM-DD. --date_to: End of a date range for when a conda package was published. Format: YYYY-MM-DD.
A maximum span of one year is allowed between the start and end of the date range.

Viewing mirror status

To view the status of a mirror:
Example output:

Stopping and restarting a mirror

To stop an in-progress mirror:
To restart a stopped mirror:

Updating a mirror

To update an existing mirror, use the --update argument with the same mirror arguments used during creation:
For example:
If you do not include the --run_now argument, your mirror updates on its next scheduled run. Run conda repo mirror --update <MIRROR_NAME> --channel <CHANNEL_NAME> --run_now to trigger an immediate update without changing any parameters.
Updating a mirror replaces its current contents with what you specify in the update command.

Deleting a mirror

To delete a mirror:
When you create a conda mirror with filter arguments, Package Security Manager also creates a policy named <MIRROR_NAME>_<ID>. Deleting the mirror doesn’t delete this policy. To remove it, find its ID with conda repo policy --list-all, and then run conda repo policy --delete <POLICY_ID>.