If you have a bunch of Debian machines to be taken care of, you must have been using APT a lot. APT is incredible, but if you use it to update multiple machines, you’ll be bored to death waiting each and individual machine to download packages. What if I tell you there’s a way we can download once, use multiple times? That’d be great, wouldn’t it?
- A machine with at least 20GB disk space (to be the repository server) – http://www.debian.org/mirror/size
- rsync (to sync with the repository)
- Port 873 opened in the firewall (for rsync to access Debian mirrors)
Preparing the server
First, you need to download the script http://www.debian.org/mirror/anonftpsync
Change the following variables in the script:
- TO : put in the path where you want to save your repository
- RSYNC_HOST : put the mirror closest to you (http://www.debian.org/mirror/list-full)
- EXCLUDE : put in the architectures that are useless for you. In my case, I exclude all architecture except for i386
Make the directory you specified in TO variable above.
Next, test your script:
# sh anonftpsync
If you can see the files being downloaded in the file rsync.log generated by the script, it is working. Go have a coffee or a nap, as the first sync takes a lot of time 🙂
If you have verified that all files have been downloaded properly, save the script to /usr/local/sbin/anonftpsync
Don’t forget to:
# chmod 755 /usr/local/sbin/anonftpsync
This is just the matter of asking cron to do the job for you, say at 6.30am everyday:
30 6 * * * /usr/local/sbin/anonftpsync
You are done! Now your ‘APT Server’ will sync itself with the chosen mirror everyday. In the next part of this article we’ll configure a machine to utilize this server.