Skip to content

Instantly share code, notes, and snippets.

@Markario
Created November 2, 2020 21:22
Show Gist options
  • Save Markario/d12d7e90d855497b52841c98726fbcd2 to your computer and use it in GitHub Desktop.
Save Markario/d12d7e90d855497b52841c98726fbcd2 to your computer and use it in GitHub Desktop.
Backup org repos
#!/bin/bash
ORG_NAME="org name"
ACCESS_TOKEN="your access token"
GITHUB_INSTANCE="api.github.com"
URL="https://${GITHUB_INSTANCE}/orgs/${ORG_NAME}/repos?direction=asc&per_page=100"
curl -H "Authorization: token $ACCESS_TOKEN" ${URL} | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone --mirror #{repo["ssh_url"]} ./#{repo["name"]}/.git && cd ./#{repo["name"]} && git config --bool core.bare false && git checkout ]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment