Go program that utilizes the Github API to backup all repositories for a user. In addition, it can backup starred repositories and gists.
- Create a Github personal access token with the following scopes:
read:user, repo
- Either download a binary for your system from releases, or build the program yourself with
go build
- Create a
.env
file - Add
GITHUB_TOKEN = TOKEN
to.env
(replace TOKEN with your token) - Run the binary in the same folder as your
.env
file
These are examples, for full usage info, run gobackup-github --help
gobackup-github
- Use the interactive UIgobackup-github backup repos
- Backup your repositoriesgobackup-github backup gists
- Backup your gistsgobackup-github backup stars
- Backup your starred repositoriesgobackup-github repos stars
- Backup your repositories and your starred repositoriesgobackup-github backup --create-list --no-clone repos stars
- Record the names and URLs of starred and owned repositories, without cloning them
This program can also be run in Docker.
To pull the program, run docker pull ghcr.io/slashtechno/gobackup-github:latest
An example of running the program in Docker:
docker run --rm -it --name gobackup-github -v ${PWD}/backups:/backups --env-file ${PWD}/.env ghcr.io/slashtechno/gobackup-github gobackup-github backup -d /backups -c repos gists
It can also run with a loop that runs every 24 hours:
docker run -it -d --name gobackup-github -v ${PWD}/backups:/backups --env-file ${PWD}/.env ghcr.io/slashtechno/gobackup-github gobackup-github backup -d /backups -r -c repos gists
I wanted a simple way to backup my Github repositories. I also wanted to learn Go and APIs. Thus, I started this project as a way to create my first Go project, use the Github API, and make a utility to backup Github repositories.