Setting up an apt repository mirror

The method of setting up an apt repository mirror described below uses our own script, built in house. If you wish to use another method, feel free. But we cannot provide support beyond issues on our end.

Requirements:

  • A server that is internet-facing (publicly accessible)
  • Linux OS installed on said server with the following installed (Ubuntu/Debian package names provided):
    • bash
    • wget
    • coreutils
    • findutils
  • At least 5 GB of disk space available, after your OS and any other necessary files, preferably more

You will also need our mirror updater script, which you can download here:

Download

 

Step 1

Once you have downloaded this script, place it on your server, and set it’s permissions so it is:

  • not publicly readable, or executable
  • executable by you and/or the system.
  • Is not writable by anyone

Step 2

Place 2 files named DESTINATION.conf and LOG.conf in the same directory as the script. Make sure only you can edit them, and the script can read them.

Step 3

Set the destination for the apt repository mirror in DESTINATION.conf. Make sure to give it the full file path. DO NOT use the $HOME variable or the “~” shortcut.

Step 4

Set the log destination in LOG.conf. The same rules that applied to DESTINATION.conf apply here too.

Step 5

Next, make sure that the destination you have set is not named “draugeros.org”. Wget downloads to a folder named this, and this folder gets deleted after the update procedure is complete.

Step 6

Finally, set a cron job to run this script however often you would like. Expect it to download about 1 GB of data each time it updates, so set your timing accordingly.

You can set a cron job from the command line like so:

crontab -e

Once it opens the file, if you have not set the default text editor, it will likely open the file in vi or vim. Use these instructions to get to edit mode, then save and exit afterwards.

At the bottom of the file, on it’s own line, insert a line with the following syntax:

[timing] /bin/bash /path/to/mirror-updater.sh [output]

For the timing, we suggest putting either:

  • 0 * * * * (sets to run at the top of every hour)
  • 0 0 * * * (sets to run at midnight every day)

So, if you wanted the cron job to run every day and the output to be trashed, we would put:

0 0 * * * /bin/bash /path/to/mirror-updater.sh 1>/dev/null

Afterwards, simply save and exit, and we’re done! Thanks for setting up an apt repository mirror! Please contact us and let us know! This way, we can let you know if there are errors on our end, so you can prevent the errors trickling down to you.