Skip to content

chai-ji/github-backup

Repository files navigation

Github Backup Scripts

Scripts to help you backup your repos from GitHub.

Requirements

Install dependencies and log in with a PAT from GitHub

brew install jq gh

# login to gh with fine-grained personal access token;
# generate PAT https://github.com/settings/personal-access-tokens
# - Repository access: All repositories
# - Repository permissions: contents - read only ; metadata - read only
# - Account permissions: Profile - read only ; Git ssh keys - read only
gh auth login

# check login status
git auth status

API Rate Limits

Note the GitHub API Limits described here

Primary rate limit for authenticated users All of these requests count towards your personal rate limit of 5,000 requests per hour.

About secondary rate limits No more than 900 points per minute are allowed for REST API endpoints, and no more than 2,000 points per minute are allowed for the GraphQL API endpoint. No more than 90 seconds of CPU time per 60 seconds of real time is allowed. You can roughly estimate the CPU time by measuring the total response time for your API requests.

If you exceed your primary rate limit, you will receive a 403 or 429 response

Usage

Create a list of all your repos

./get_repos_lists.sh <username>
  • this script will search all your commits to find repos, this might take several minutes to complete
  • see notes about which repos are retrievable this way

Use the output file to download clones of all repos in the list

./download_repos.sh deduped_repos.txt

NOTES

Fine Grained PAT cannot see membership in private Orgs, or private membership in some public Orgs. Need Classic Token for that (read:org).

need this for gh api user/orgs ; gh api users/<username>/orgs only shows public memberships

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages