Skip to content

Instantly share code, notes, and snippets.

Created February 5, 2015 16:57
Show Gist options
  • Save anonymous/aebb4a0639b0af2cfd88 to your computer and use it in GitHub Desktop.
Save anonymous/aebb4a0639b0af2cfd88 to your computer and use it in GitHub Desktop.
Backup starred GitHub repositories
#!/bin/bash
user="CHANGEME"
pages=$(curl -I https://api.github.com/users/$user/starred | sed -nr 's/^Link:.*page=([0-9]+).*/\1/p')
for page in $(seq 0 $pages); do
curl "https://api.github.com/users/$user/starred?page=$page&per_page=100" | jq -r '.[].html_url' |
while read rp; do
git clone $rp
done
done
@snowman
Copy link

snowman commented Oct 30, 2019

$(seq 0 $pages) should start at 1, per_page=100 should be 30, otherwise will be duplicate?

@fbaew
Copy link

fbaew commented Jun 14, 2020

Also it looks like you need to change Link to link these days.

@stevesimmons
Copy link

Also it looks like you need to change Link to link these days.

I found the GitHub API returned header named link when calling curl as an unauthenticated user and Link when authenticated (i.e. curl -u $USER:$TOKEN .... Both cases are covered when the regex is 's/^[Ll]ink:....

@dm17
Copy link

dm17 commented Nov 1, 2020

Also it looks like you need to change Link to link these days.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment