3.0 KiB
github-backup-cli
The problem: a GitHub account can get flagged, hacked, or suspended, and every repo on it becomes unreachable until (or unless) it's fixed. It happens to real accounts, not just hypothetical ones.
One command gets you a copy you hold yourself, independent of GitHub's decisions about your account.
npx github-backup-cli torvalds
That clones every repo (full history, every branch and tag) into
./github-backup-torvalds/, plus an issues.json and releases.json
per repo. No GitHub token needed for public repos.
Backing up your own (incl. private) repos
export GITHUB_TOKEN=ghp_xxx # a GitHub personal access token
npx github-backup-cli --dest ./my-backup
With a token and no username, it backs up the token owner's own repos (owner-affiliated only, not org repos you don't own).
Pushing the backup somewhere other than a local folder
npx github-backup-cli myuser --remote "ssh://git@myserver/backups/{repo}.git"
{repo} is replaced with each repo's name. This works with any git
remote — your own server, another host, anything that accepts
git push --mirror.
Optional: mirror straight into Rithub
If you'd rather not run your own git server, Rithub
hosts it for you. --to rithub mirrors every repo into a Rithub account
in the same run, using Rithub's own migrate API (no local clone needed
for this part, though you can do both at once):
npx github-backup-cli myuser --to rithub \
--rithub-user myuser --rithub-token $RITHUB_TOKEN
Rithub access tokens: Settings → Applications → Generate New Token on
your Rithub account. RITHUB_USER / RITHUB_TOKEN / RITHUB_HOST
environment variables work the same as the flags.
Already-mirrored repos are skipped on re-runs, so this is safe to run on a schedule.
All options
npx github-backup-cli <github-user> [options]
<github-user> GitHub username to back up (required unless
--token is set, in which case it backs up the
token owner's own repos)
--dest <dir> Local folder for the mirrors (default:
./github-backup-<user>)
--token <token> GitHub token (env GITHUB_TOKEN)
--no-meta Skip issues/releases JSON export
--no-local Skip the local mirror clone
--remote <template> Push each mirror to a git remote too,
"{repo}" replaced with the repo name
--to rithub Also migrate every repo into a Rithub account
--rithub-user <user> Rithub account to receive repos
--rithub-token <token> Rithub access token
--rithub-host <host> Rithub host (default rithub.dev)
What this does not back up
Pull request review threads, project boards, GitHub Actions run history, and GitHub Pages deployments are not covered — those live in GitHub's own systems beyond a repo's git data and REST-visible issues and releases.
Requirements
Node.js 18+, and git on your PATH. No other dependencies.
License
MIT