A small Go CLI that backs up your GitHub repositories by cloning each repo in two formats:
- a mirror clone (
--mirror) for complete Git history and refs - a standard clone for easy browsing of files
- Reads
GITHUB_TOKENfrom a local.envfile. - Uses the GitHub API to get your username and repository list.
- Clones each repository under
./backup/<owner>/<repo>/as:<repo>.git(mirror clone)<repo>(normal clone)
- Prompts to move the backup into a timestamped folder under
./snapshots/.
- Go 1.26+
- Git installed and available on
PATH - A GitHub personal access token in
.env
-
Copy the example env file:
cp .env.example .env
-
Edit
.envand set your token:GITHUB_TOKEN=your_token_here
Run the tool from the repository root:
go run .After cloning, confirm the prompt to move the backup to a snapshot folder.
Build:
go build ./...Test:
go test ./...- Keep your
.envfile private and never commit it. - The token is embedded in clone URLs at runtime for authentication.
- Large accounts may take time to back up depending on repository count and size.