Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Create Your Own Debian 8 (Jessie) Mirror

To setup a Debian 8 mirror, please refer to my tutorial on setting up an ubuntu mirror, but change the contents of the /etc/apt/mirror.list file to contan the following:

...
############# end config ##############
# copy below this line

# debian mirror
deb-amd64 http://ftp.uk.debian.org/debian jessie main contrib non-free
deb-amd64 http://ftp.uk.debian.org/debian jessie-backports main contrib non-free
deb-amd64 http://ftp.uk.debian.org/debian jessie-updates main contrib non-free
deb-amd64 http://ftp.uk.debian.org/debian jessie-proposed-updates main contrib non-free

deb-i386 http://ftp.uk.debian.org/debian jessie main contrib non-free
deb-i386 http://ftp.uk.debian.org/debian jessie-backports main contrib non-free
deb-i386 http://ftp.uk.debian.org/debian jessie-updates main contrib non-free
deb-i386 http://ftp.uk.debian.org/debian jessie-proposed-updates main contrib non-free

deb-src http://ftp.uk.debian.org/debian jessie main contrib non-free
deb-src http://ftp.uk.debian.org/debian jessie-backports main contrib non-free
deb-src http://ftp.uk.debian.org/debian jessie-updates main contrib non-free
deb-src http://ftp.uk.debian.org/debian jessie-proposed-updates main contrib non-free

clean http://ftp.uk.debian.org/debian

i18n

Unfortunately, this won't sync the translation files within the i18n directories, so we need to create a script with the following contents that will do this for us after apt-mirror has finished.

sudo apt-mirror

cd /var/spool/apt-mirror/mirror/ftp.uk.debian.org/debian/dists/jessie

for master_directory in jessie jessie-updates jessie-backports; do
    cd $master_directory

    for directory in contrib main non-free; do
        cd $directory
        mkdir i18n 2>/dev/null
        cd i18n
        rm Translation-en*
        wget http://ftp.uk.debian.org/debian/dists/$master_directory/$directory/i18n/Translation-en.bz2
        cd ../../
    done

    cd ..
done

Now just configure a cron job to call that script every day.

Example Sources File

To use your local mirror simply replace the file at /etc/apt/sources.list with the following contents (replacing my.domain.com)

deb http://my.domain.com/debian/ jessie main
deb-src http://my.domain.com/debian/ jessie main

deb http://my.domain.com/debian/ jessie-updates main
deb-src http://my.domain.com/debian/ jessie-updates main

# security updates
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

#deb http://my.domain.com/debian/ jessie-backports main
#deb-src http://my.domain.com/debian jessie-backports main

Feel free to uncomment the backports line at your own risk after reading about what they are.

References

Last updated: 17th April 2021
First published: 16th August 2018