22 lines
560 B
Bash
Executable file
22 lines
560 B
Bash
Executable file
#!/bin/sh
|
|
|
|
ORGS="foo-sh"
|
|
|
|
set -eu
|
|
umask 027
|
|
|
|
cd /srv/backup/github.com
|
|
|
|
for _org in $ORGS ; do
|
|
curl -sSf "https://api.github.com/orgs/foo-sh/repos" | jq -r '.[] | .name' | \
|
|
while read -r _repo
|
|
do
|
|
_url="https://github.com/${_org}/${_repo}.git"
|
|
_gitdir="${_org}/${_repo}"
|
|
if [ ! -d "$_gitdir" ]; then
|
|
mkdir -p "$_gitdir"
|
|
git --git-dir="$_gitdir" init --quiet --bare
|
|
fi
|
|
git --git-dir="$_gitdir" fetch --quiet --force --prune --tags "$_url" "refs/heads/*:refs/heads/*"
|
|
done
|
|
done
|