Responsive image
Date 2021-08-18 02:00

I love mirroring Linux distributions via bittorrent from a seedbox. When Debian 11 came out I wanted to make sure I was mirroring all those bittorrents.


Previously I was manually going through cdimage on cdimage.debian.org trying to find all the *.torrent in a browser.


Eventually, I thought there had to be a better way. So, I found one!


Basically, here is what I did:

$ mkdir ~/downloads/debian_rsync
$ mkdir ~/downloads/debian_bittorrents
$ rsync -ravm --progress --include="*-11.0*.torrent" --include="*/" --exclude="*" rsync://cdimage.debian.org/cdimage ~/downloads/debian_rsync
$ cd ~/downloads/debian_rsync
$ shopt -s globstar
$ mv **/*.torrent ~/downloads/debian_bittorrents

Then for the unofficial mirror:

$ mkdir ~/downloads/debian_rsync2
$ rsync -ravm --progress --include="*-11.0*.torrent" --include="*/" --exclude="*" rsync://cdimage.debian.org/cdimage-unofficial ~/downloads/debian_rsync2
$ cd ~/downloads/debian_rsync2
$ mv -i **/*.torrent ~/downloads/debian_bittorrents

Now ~/downloads/debian_bittorrents will have all the Debian 11 bittorrents from cdimage.debian.org.


One of the tricks to make this work so you don't end up with so many useless folders is the -m option on rsync. This option only creates local folder that contain files that match the pattern you are looking for.


Other things I tried was searching for rsync flags that would ignore the directory structure upon copying, or flatten the output of rsync. Most of these solutions require local access to the files you are trying to copy and wouldn't have worked for this puzzle.


Comments

comments powered by Disqus

where randomness meets the internet


~ About me ~
just a human doing random things
~ Follow me ~