Skip to content

Commit a08771c

Browse files
committed
feat: add backup GH repos shell script
1 parent abdd22f commit a08771c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Linux-Bash/backup-github-repos.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
dirname=github-backup-$(date "+%Y-%m-%d-%H-%M-%S")
4+
mkdir "$dirname"
5+
cd $dirname
6+
7+
#change these vars:
8+
privateToken=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
9+
userName=jimbrig
10+
11+
curl -H "Accept: application/vnd.github.nebula-preview+json" \
12+
-H "Authorization: token $privateToken" \
13+
"https://api.github.com/user/repos?visibility=all&affiliation=owner&per_page=200" \
14+
| jq -r '.[] | .name' \
15+
| while IFS= read projectName; do
16+
curl -H "Authorization: token $privateToken" -H "Accept: application/vnd.github.v3.raw" -L \
17+
"https://api.github.com/repos/$userName/$projectName/zipball" --output $projectName.zip
18+
done
19+
20+
echo Done! All files downloaded here: $(pwd)

0 commit comments

Comments
 (0)