Creating an official Debian mirror with apt-mirror, debmirror or ftpsync

In this article I'll demonstrate 3 ways of creating a local Debian mirror using the apt-mirror, debmirror and the ftpsync tools. I'll be mirroring Debian Wheezy, which will download about 79GB of packages. If your environment consists of many server builds each day, having a local Debian mirror will save you time and bandwidth.

I'll be using a Debian Wheezy server for this purpose.

First install the apt-mirror package and apache:

The apt-mirror config file is /etc/apt/mirror.list and should contain the following:

You can put whatever mirror is closer to you and  add or remove different repository sections. In this example I am interested in mirroring the main, contrib and the non-free sections.

Now that the config is there just run:

This will have the packages downloaded to

Let's expose the repo over HTTP:

And use it:

In some cases you might need to have a stable section in your repo. In this case you can just create a symlink to Wheezy:

To keep the repository in sync with the upstream Debian you can create a cronjob that pulls new packages at midnight:

Alternatively you can mirror any repo e.g. Percona using debmirror with this one liner:

The recommended way of mirroring Debian repository is by using the ftpsync mirroring tool [1].

Let's install it and configure it to mirror wheezy and squeesze:

The config file should at a minimum look like this (if you only want to mirror i386 and amd64 architectures):

With all that in place time to rsync the files:

Or if you rather run the two rsync stages one at a time, execute:

This really just runs these two rsync commands one after the other:

To mirror the OpenVZ repo at first let's find what rsync shares are supported:

After some trial and error the openvz-download is the share that works. The config file should look like so:

To rsync the repo run:
Notice how the config file has the OPENVZ name in it and how we specify which config to run by passing the sync:archive:OPENVZ parameters to the ftpsync script.



  1. Some Linux technologies evolve so fast that their configurations go out of date quickly. Any chance for dating your articles? Then it would be easy to find the publication date without doing any detective work (reading comments or install messages).

  2. You can see the date I wrote the article in the URL e.g. As of that date you should be able to copy-paste my examples and they should work.

  3. I like the date in the URL. However, "modern" devices like phones and tablets don't like to show you the URL. I really hate that. Seriously. If there was a vote, I would be in favor of having a time stamp as part of the template. I found the content above very useful. Unfortunately, that's relevant to the date of publication as the first poster pointed out.

    Regardless, thank you Konstantin for sharing. Any insights as to why ftpsync is preferred to debmirror? Perhaps security?

  4. Point taken. I'll insert dates to the posts. As for why ftpsync is the recommended way by Debian is because it uses the two stage rsync process as per where debmirror does not.

  5. Hello,

    Thanks for the Super Guide.

    How it looks with a crontab? Would like the bin / ftpsync sync: running all all four hours! My system is Debian 7

    Thank you in advance in advance.


    1. Since ftpsync uses rsync to transfer data, it should be ok to run in crontab every few hours, because after the first run it will only copy the deltas.

    2. Vielen Dank für die Infos :)

      Und beste grüße aus Deutschland.

  6. I expect that "--exclude=jessie*" will avoid the meta-data about the jessie suite, but will still download all the packages used by it, even if they aren't used by wheezy, the targeted suite. Isn't it true that though you plan to "be mirroring Debian Wheezy", you're actually mirroring the entire repository of debs (for particular architectures)?

  7. Thank you for the tutorial, I would like to add that if anyone runs into the following error:
    /debian/dists/wheezy-updates/main/i18n/Translation-en 404 Not Found
    This is a known bug:

    You can fix as follows:
    Applying manual update to postmirror script
    dpkg-query -l apt-mirror

    locate apt-mirror

    mv /usr/bin/apt-mirror ~/BADapt-mirror

    cd ~
    apt-get install git
    git clone apt-mirror
    cd apt-mirror
    cp -iv apt-mirror /usr/bin/apt-mirror

    Note that:
    cat /var/spool/apt-mirror/var/
    shows an empty file for me, so only one file was required to be updated.