A simple CLI tool to back up all of your GitHub repositories as local mirror clones.
- Backs up all repositories (public, private, and forks) for your authenticated GitHub account
- Uses
git clone --mirrorto create complete mirror clones including all branches, tags, and refs - Stores OAuth tokens securely in your system keyring; no config files with plain-text credentials
- Handles GitHub API pagination automatically
- Runs up to 5 repository operations concurrently
- Handles
SIGTERMandSIGINT(Control+C) gracefully
- Go 1.22 or later
- Git installed and available in
PATH - A GitHub account
brew tap ChrisWiegman/backup-github
brew install backup-githubgo install github.com/ChrisWiegman/backup-github/cmd/backup-github@latestPre-built binaries for macOS are available on the Releases page.
Run the command from the directory where you want your backups to be saved:
backup-githubOn first run you will be prompted to authenticate with GitHub via OAuth. The token is saved to your system keyring so subsequent runs do not require re-authentication.
By default, repositories are cloned into the current working directory:
./
├── my-repo/
├── another-repo/
└── forked-repo/
Use --output-dir to specify a different destination — absolute, relative, or home-relative paths are all supported:
backup-github --output-dir ~/backups
backup-github --output-dir /mnt/external/github
backup-github --output-dir backupsEach directory is a bare mirror clone. Re-running backup-github will clone any new repositories and update existing ones via git remote update.
Progress is printed to the terminal as each repository is processed:
[1/47] Cloning my-new-repo
[2/47] Updating existing-repo
[3/47] Updating another-repo
| Flag | Short | Default | Description |
|---|---|---|---|
--output-dir |
-o |
current directory | Directory to write backups into (absolute, relative, or ~/…) |
--verbose |
-v |
false |
Enable verbose (detailed) output |
Display the current version and build time:
backup-github versionRemove the stored GitHub OAuth token from your system keyring. The next run of backup-github will prompt you to reauthenticate.
backup-github logoutThe app requests the following GitHub scopes during authentication:
| Scope | Purpose |
|---|---|
repo |
Access private repositories |
read:org |
Read organization membership |
gist |
Access gists |
make installThis compiles the binary with the current git tag as the version and installs it to $GOPATH/bin.
make testmake lintRequires golangci-lint. The linter is installed automatically if not found.
make updateThis project uses Changie for changelog management.
Add a new changelog entry:
make changeCut a release changelog:
make changelogMIT — see LICENSE.txt.