Skip to content

Instantly share code, notes, and snippets.

@MartinHarding
MartinHarding / backup-github.sh
Last active March 11, 2020 17:11 — forked from darktim/backup-github.sh
If you have more than 30 Repositories, the original script will not download all. The github api limits the entries to 30 per page but you can raise that up to 100. I have added a small loop which sets the limit to 90 and cycles through all pages until the listing on a page is empty...
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
[[ -z "$GHBU_ORG" ]] && echo "Please set GHBU_ORG" && exit 1
[[ -z "$GHBU_UNAME" ]] && echo "Please set GHBU_UNAME" && exit 1
[[ -z "$GHBU_PASSWD" ]] && echo "Please set GHBU_PASSWD" && exit 1
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=$GHBU_ORG # the GitHub organization whose repos will be backed up
GHBU_UNAME=$GHBU_UNAME # the username of a GitHub account (to use with the GitHub API)