How do I create a Debian mirror?

This is a bit more complicated, but here you go:


First we install the package from the debian team which helps us setting up the mirror:

aptitude install debmirror

Always a good idea: create a own user for this operation:
(replace PATH with the path where you would like to put the files)

groupadd mirror
useradd -g mirror -d /PATH -c "Debian Mirror" mirror

mkdir -p /PATH/debian
mkdir /PATH/security
chown -R mirror:mirror /PATH


Now we need to install the GPG key of the Debian FTP masters:
(so before synching our server will check the signature for every file)

aptitude install debian-keyring
su mirror -c "gpg --import /usr/share/keyrings/debian-role-keys.gpg"
su mirror -c "GET http://ftp-master.debian.org/ziyi_key_2006.asc | gpg --import"


So now we drop our privileges to the user "mirror":

su mirror


After that we start the mirroring scripts:
(you may use other mirrors then ftp.de.debian.org of course)

debmirror /PATH/debian --passive --progress --nosource --host=ftp.de.debian.org --root=/debian --dist=sarge,etch,sid --section=main,contrib,non-free --arch=i386 --cleanup
debmirror /PATH/security --passive --progress --nosource --host=security.debian.org --root=/debian-security --dist=sarge/updates,etch/updates --section=main,contrib,non-free --arch=i386 --cleanup


As this has worked, we now need to make some symlinks so stable, testing and unstable work too:

cd /PATH/debian/dists
ln -s sarge stable
ln -s etch testing
ln -s sid unstable
cd /PATH/security/dists
ln -s sarge stable
ln -s etch testing


To make everything automated you could now setup those two debmirror commands within cron.


Enjoy!

You cannot comment on this entry