The easiest way to create an apt-get mirror is to use apt-mirror.

Setup[edit]

On a debian/ubuntu machine, run:

 apt-get install apt-mirror

Configure[edit]

apt-mirror will read /etc/apt/mirror.list as its configuration file. Below is the mirror file I currently am using:

 1 # This is the mirror.list configuration used by apt-mirror
 2 #
 3 # To create a local apt repository, put this in /etc/apt/mirror.list
 4 # then run apt-mirror
 5 #
 6 
 7 ############# config ##################
 8 #
 9 # set base_path    /var/spool/apt-mirror
10 #
11 set mirror_path  /mnt/file
12 # set skel_path    $base_path/skel
13 # set var_path     $base_path/var
14 # set cleanscript $var_path/clean.sh
15 # set defaultarch  <running host architecture>
16 # set postmirror_script $var_path/postmirror.sh
17 # set run_postmirror 0
18 set nthreads     20
19 set _tilde 0
20 #
21 ############# end config ##############
22 
23 # Mate desktop stuff
24 deb http://packages.mate-desktop.org/repo/ubuntu quantal main
25 deb-src http://packages.mate-desktop.org/repo/ubuntu quantal main
26 
27 # Main ubuntu stuff
28 deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal main restricted main/debian-installer restricted/debian-installer
29 deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-updates main restricted main/debian-installer restricted/debian-installer
30 deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-backports main restricted main/debian-installer restricted/debian-installer
31 deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-security main restricted main/debian-installer restricted/debian-installer
32 
33 # Salt stack stuff
34 deb http://ppa.launchpad.net/saltstack/salt/ubuntu quantal main

Usage[edit]

Once you've defined your mirror.list file, run apt-mirror to create a copy of the mirrors. It will tell you the amount of data it will need to download along with the statuses of each thread that is running.

root@host# apt-mirror
Downloading 81 index files using 20 threads...
Begin time: Mon Apr 29 12:00:09 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]...
End time: Mon Apr 29 12:00:10 2013

Proceed indexes: [SPPPPPP]

219.8 MiB will be downloaded into archive.
Downloading 639 archive files using 20 threads...
Begin time: Mon Apr 29 12:00:18 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]...
End time: Mon Apr 29 12:00:47 2013

0.0 bytes in 0 files and 0 directories can be freed.
Run /var/spool/apt-mirror/var/clean.sh for this purpose.

Running the Post Mirror script ...
(/var/spool/apt-mirror/var/postmirror.sh)


Post Mirror script has completed. See above output for any possible errors.

You have new mail in /var/mail/root