Skip to content

neoRandom/github-backup-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Backup Tool

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

How it works

  1. Reads GITHUB_TOKEN from a local .env file.
  2. Uses the GitHub API to get your username and repository list.
  3. Clones each repository under ./backup/<owner>/<repo>/ as:
    • <repo>.git (mirror clone)
    • <repo> (normal clone)
  4. Prompts to move the backup into a timestamped folder under ./snapshots/.

Requirements

  • Go 1.26+
  • Git installed and available on PATH
  • A GitHub personal access token in .env

Setup

  1. Copy the example env file:

    cp .env.example .env
  2. Edit .env and set your token:

    GITHUB_TOKEN=your_token_here

Usage

Run the tool from the repository root:

go run .

After cloning, confirm the prompt to move the backup to a snapshot folder.

Development

Build:

go build ./...

Test:

go test ./...

Important notes

  • Keep your .env file 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.

About

Backup all GitHub repositories that your account has access to, public or private

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors