Updated 2026-11-30
GitHub's own redundancy protects GitHub, not you — if your account gets suspended, flagged, or deleted by mistake, their backups don't restore your access. The fix is a one-time script that mirrors every repo you own to a second host, done before anything happens, not after.
Using the GitHub CLI (gh):
gh repo list <you-or-your-org> --limit 1000 --json nameWithOwner -q '.[].nameWithOwner' > repos.txt
This gives a plain text list, one owner/repo per line, including private repos you have access to.
while read repo; do git clone --mirror "https://github.com/$repo.git" "backup/$repo.git" done < repos.txt
--mirror captures every branch and tag, not just the default branch — this is the same format you'd push from to restore the repo elsewhere.
A local backup alone is one point of failure away from being useless. Push each mirror to a host you don't depend on GitHub's policies for:
cd "backup/$repo.git" git remote add rithub "https://rithub.dev/$repo.git" git push rithub --mirror
Script this across the full repos.txt list and you have a second, working copy of every repository, independent of GitHub's account status.
A backup taken once goes stale. Re-run the same mirror-clone-and-push loop on a schedule (a weekly cron job, or after any repo you care about gets new commits) so the backup copy is never far behind the original.
Does GitHub back up my repos for me?
Only against GitHub's own infrastructure failures — not against account suspension, flags, or accidental deletion on your side.
Fastest way to back up everything?
List repos via gh repo list, loop git clone --mirror over the list.
Where should backups live?
Not only on one disk — push mirrors to a second, independently-run host too.