Skip to main content

apt-mirror2

apt-mirror2 is the Python/asyncio reimplementation of the apt-mirror developed as drop-in replacement for the latest.
This project should be suitable as general apt-mirror replacement.

One of the main advantages of the apt-mirror2 over the apt-mirror - you should never got broken mirror in case apt-mirror2 returns 0 exit code. This is ensured by data integrity checks at all stages of mirroring.

Requirements

Python 3.10 is the minimum supported version. PyPy 3.10 (7.3) is supported also.
For additional dependencies look to the pyproject.yml and/or requirements.txt.

Installation

Container (Docker/Podman)

Container images are available in the Docker Hub under aptmirror/apt-mirror2 repository and in the Red Hat Quay.io inder apt-mirror2/apt-mirror2 repository.

You can try it using

docker run -it --rm docker.io/aptmirror/apt-mirror2 --help

or

docker run -it --rm quay.io/apt-mirror2/apt-mirror2 --help

You may wish to use podman command instead of docker.

Image variants

aptmirror/apt-mirror2:latest

aptmirror/apt-mirror2:<version>

Images based on debian:stable image.

aptmirror/apt-mirror2:slim

aptmirror/apt-mirror2:<version>-slim

Images based on debian:stable-slim image.

aptmirror/apt-mirror2:alpine

aptmirror/apt-mirror2:<version>-alpine

Images based on alpine:3 image.

PyPi

PyPi package is available with the name apt-mirror:

pip install apt-mirror
apt-mirror --help

Debian and Ubuntu packages

Debian (bookworm, trixie) and Ubuntu (22.04, 24.04) packages are available in the Packagecloud repository.

Quick automated repository setup:

curl -s https://packagecloud.io/install/repositories/nE0sIghT/apt-mirror2/script.deb.sh | sudo bash

Package installation:

sudo apt-get install apt-mirror2

For manual steps please look to the Packagecloud repository.

Build from source with virtualenv

It's possible to use apt-mirror2 from a virtualenv:

# Let's work in the home folder
cd

# Create virtualenv
virtualenv ~/venv/apt-mirror2
source ~/venv/apt-mirror2/bin/activate

# Clone apt-mirror2 source code
git clone https://gitlab.com/apt-mirror2/apt-mirror2
cd apt-mirror2

# Install requirements
pip install -r requirements.txt

# Install apt-mirror2 into virtualenv
python setup.py install

apt-mirror --help

Usage

As the drop-in replacement for the apt-mirror this project supports same CLI syntax.

usage: apt-mirror [-h] [--version] [configfile]

positional arguments:
  configfile  Path to config file. Default /etc/apt/mirror.list

options:
  -h, --help  show this help message and exit
  --version   Show version

apt-mirror compatibility

Most of apt-mirror configuration directives are supported.
As of now proxy for FTP repositories is not supported.

File lists (ALL, NEW, MD5, SHA256, SHA512) are not written by default, but you can enable them with the write_file_lists option.

In addition there are some enhancements available:

  • Repositories without MD5 hashsums are correctly mirrored
  • Old index files are properly cleaned and don't produces errors in mirror processing
  • Standard source.list [ arch=arch1,arch2 ] can be used to specify multiple repository architectures for mirroring.
  • multiple codenames (or flat folders) can be specified using comma as delimiter.
  • mirror_path URL PATH option may be used to specify PATH to use for saving mirror files instead of path that is generated from URL.
  • Additional configuration is loaded from the *.list files in the directory named same as configfile with the .d suffix. Eg /etc/apt/mirror.list.d/*.list.
  • Rate limit is enforced for overall download rate.
  • Slow download rate protection is enabled by default and can be configured via mirror.list.
  • Non-zero exit code is returned if some of required files were not downloaded due to network or server errors or no repositories were configured.
  • HTTP user agent can be configured via user_agent configuration.
  • Configuration variables are exposed to postmirror_script.
  • by-hash list option can be used to control whether Acquire-By-Hash Release option should be respected or enforced.
  • mirror wipe protection is available and configurable via wipe_size_ratio and wipe_count_ratio settings.
  • per-repository log files are available in the var_path folder
  • dists folder is almost atomicaly replaced using move instead of copy/link
  • native Prometheus metrics are supported

Common problems

LocalProtocolError: Max outbound streams is n, n open

This warning may appear with HTTP2 mirrors when you have too much nthreads configured. You may either lower nthreads value or disable http2 via http2-disable option. As of now apt-mirror2 have no control over HTTP2 concurrent streams value used by httpx/h2 client but limits count of simultaneously downloaded files which still can exceeds maximum outbound streams due to unknown reason.

RuntimeError: can't start new thread

Long story short: upgrade Docker.

Look to the https://gitlab.com/apt-mirror2/apt-mirror2/-/issues/33#note_2377422047 for more solutions.

License

GNU General Public License v3.0 or later

Metadata

Release files for apt-mirror 13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apt-mirror 13
File Size Uploaded
apt_mirror-13.tar.gz 511.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apt-mirror 13
File Interpreter ABI Platform
apt_mirror-13-py3-none-any.whl Python 3 none any Details

Total release size: 577.7 kB

Release files / apt_mirror-13.tar.gz

Download URL apt_mirror-13.tar.gz
Size 511.4 kB
Tags Source
SHA-256 checksum
How to use checksums
72b7b97bd6d1b9f839a39022cf5eed759248bc0bed2d60408c93121d20e3c32a
BLAKE2b-256 checksum
How to use checksums
53313696d64ea7e9a16d041cb858e9dccafd843f258a407098be454917d94d8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / apt_mirror-13-py3-none-any.whl

Download URL apt_mirror-13-py3-none-any.whl
Size 66.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba865c66e41376bea1fe89ed2a91b8bdf92233adebec6ff126967f5273867f0e
BLAKE2b-256 checksum
How to use checksums
eb35815f611002c7141703999ac78a14b0d05f4e7143e20505ddb64698390bca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

16

2 release files

15

2 release files

14

2 release files

This release

13 This release

2 release files

12

2 release files

11

2 release files

10

2 release files

9

2 release files

8

2 release files

7

2 release files

6

2 release files

5

2 release files

4

2 release files

3

2 release files

2

2 release files

1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page