How to do resumable downloads with curl
The flag you want is --continue-at -
, which will resume the transfer from the size of the already-downloaded file.
Here’s an example of using it in practice.
curl \
--location \
--remote-name \
--continue-at - \
https://dumps.wikimedia.org/other/wikibase/commonswiki/20231009/commons-20231009-mediainfo.json.bz2
It behaves in a “sensible” way at the beginning and end of the download:
- If you haven’t downloaded anything yet, it starts downloading from the first byte of the remote file.
- If you’ve already downloaded the complete file, it stops as soon as it checks the byte count with the remote server.