The apt-mirror-updater package automates robust apt-get mirror selection for Debian and Ubuntu by enabling discovery of available mirrors, ranking of available mirrors, automatic switching between mirrors and robust package list updating (see features). It's currently tested on Python 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy (although test coverage is still rather low, see status). Until apt-mirror-updater has been rigorously tested I consider it a proof of concept (beta software) so if it corrupts your system you can't complain that you weren't warned! I've already tested it on a variety of Ubuntu systems but haven't found the time to set up a Debian virtual machine for testing. Most of the logic is exactly the same though. The worst that can happen (assuming you trust my judgement ;-) is that /etc/apt/sources.list is corrupted however a backup copy is made before any changes are applied, so I don't see how this can result in irreversible corruption.