BackHub is a simple GitHub repository backup tool that creates complete local mirrors of your repositories.
- Full repository mirroring including all branches, tags, and history
- Concurrent backup processing for multiple repositories defined in a YAML config file
- GitHub token-based authentication (to be used in an environment variable)
- Easy restoration capability due to it being local mirror
- Multi-arch and multi-OS binary for simple one-time usage
- A unique output provider with a fancy and detailed progress monitoring system
The easiest way to use Backhub is to download it from the project releases for your OS and architecture.
go install github.com/tanq16/backhub@latestgit clone https://github.com/tanq16/backhub.git && \
cd backhub && \
go buildBackhub uses an environment variable to authenticate to GitHub. To do this, set your GH_TOKEN variable. This can be done inline with:
GH_TOKEN=pat_jsdhksjdskhjdhkajshkdjh backhubAlternatively, export it to your shell session with:
export GH_TOKEN=pat_jsdhksjdskhjdhkajshkdjhWith the environment variable exported, backhub can be directly executed multiple times from the command line like so:
# config file
backhub /path/to/config.yaml
# direct repo
backhub github.com/tanq16/backhubBackHub uses a simple YAML configuration file:
repos:
- github.com/username/repo1
- github.com/username/repo2
- github.com/org/repo3For Docker, put the config file in the mounted directory and name it config.yaml.
To use a local mirror as a Git repository source (like when you need to restore from the backup), the following can be done:
- Directly pull or clone from the mirror treating it as a
backupremote in an existing repository:git remote add backup /path/to/your/mirror.git git pull backup main # or any other branch git clone /path/to/your/mirror.git new-repo - Serve the mirror via a local git server and use it :
git daemon --base-path=/path/to/mirror --export-all git clone git://localhost/mirror.git # in a different path - Use the mirror as a git server by refering to it through the file protocol:
git clone file:///path/to/mirror.git
Being a mirror, it contains all references (branches, tags, etc.), so cloning or pulling from it allows accessing everything as if it's the original. Use git branch -a to see all branches and git tag -l to see all tags in the mirror.
