← Back to Tools
Open Source Tool
GitHub Backup
Bash script that snapshots every GitHub repository in your account — public and private. Uses the GitHub API to enumerate repos automatically, clones each one, and compresses to timestamped archives. Run it manually or on a daily cron schedule.
View on GitHub ↗
GitHub is not a backup. If your account is compromised, a repo is deleted, or GitHub has an outage — you need an independent copy. This script makes that copy automatic.
What it does
- Automatically enumerates all repos in an account via the GitHub API
- Backs up both public and private repositories
- Creates timestamped tar.gz archives per repo for easy versioning
- Works with personal access tokens or fine-grained tokens
- Minimal dependencies — pure Bash, curl, and git
- Cron-ready — runs unattended, logs output per run
Quick start
# Clone the repo git clone https://github.com/mylesagnew/github-backup cd github-backup # Set your GitHub token and username export GITHUB_TOKEN=ghp_your_token_here export GITHUB_USER=your_username # Run backup — archives all repos to ./backups/ ./backup.sh # Schedule daily at 3am via cron # 0 3 * * * /path/to/github-backup/backup.sh >> /var/log/github-backup.log 2>&1
Related resources
Get notified when new tools and checklists drop.
Join Security Tool Updates →