Backup your GitHub repositories now!
Over the past few days, I've been seeing a surge of posts on Twitter regarding GitHub account suspension.
This isn't new. In February 2024, even GitHub's co-founder and ex-CEO, Chris Wanstrath, had his account suspended. Of course, GitHub immediately responded and removed the suspension for him but the rest of us may not be so fortunate.
Here's a bunch of other such incidents
- A student lost access to their bachelor's thesis and work repositories for 2 months due to GitHub Education verification issues
- Developers waiting up to 120 days for appeal responses
- Account suspended when trying out Codespaces and no response for over a month
- Account suspended when submitting multiple bug reports
GitHub's automated systems can flag accounts without warning, and appeals can take months. The solution? Keep your own backups.
Backup with gickup
I'm using gickup to backup my repositories hosted on GitHub. I run it on Kubernetes as a CronJob, but you can also use gickup's built-in cron runner.
I schedule daily backups, which is sufficient since actively developed repos are typically already cloned on my machine.
I'm currently backing up to the local filesystem, which is backed up separately but gickup also offers backing up to various remotes like - GitLab, Gitea, Gogs, OneDev, Sourcehut, S3.
Disclaimer: This post is not sponsored or affiliated with gickup in any way. I'm sharing my personal backup solution that works for me. See the "Alternative Tools" section at the end for other options.
Setup
- Create a GitHub Personal Access Token with
reposcope - https://github.com/settings/personal-access-tokens - Configure - create a
conf.yamlwith your GitHub username and backup destination
Here's my conf.yaml
source:
github:
- token: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
user: adityathebe
exclude:
- adityathebe/DefinitelyTyped # too Large, idc
- DefinitelyTyped
destination:
local:
- path: '/data/github-backups'
structured: true
mirror: true
lfs: false # setting this true was 100x slowerInstead of providing the github token on the config file, you can also set the
GITHUB_TOKENenv var.
Key points:
- Source: All my GitHub repositories (excluding a few large ones)
- Mirror mode: This backs up all git refs (branches, tags, and pull request refs)
- Structured: Creates organized folders for each repository
Once configured, it's completely hands-off.
Restoration
git clone gickup/github-backups/github.com/adityathebe/nvim.gitCloning into 'nvim'...
done.
admin@truenas[/mnt/mega/aditya/backups]$Alternative Tools
While I use gickup, there are several other tools available for backing up GitHub repositories:
- git-backup - A simple tool for backing up git repositories
- Gitea mirror feature - Use Gitea's built-in mirroring capabilities to backup repositories
- GitHub-Backup - Another backup solution for GitHub repositories
Note: I haven't personally tested these alternatives, but they may better suit your specific needs.