github-repos-backup-tools v1.6.1

Professional solution for automatic cloning and backup of all your GitHub repositories

Full backup of public and private repositories, smart updates, automatic retries, and detailed reports.

Python CLI GitHub Backup Repository Cross-Platform

github-repos-backup-tools — a professional solution for automatic cloning and backup of all your GitHub repositories. Full backup of public and private repositories, smart updates, automatic retries, and detailed reports.

You can also use my other projects to work with repositories:

  • Full Backup — clones ALL repositories (public and private) from your account and organizations
  • Smart Update — compares local commits with GitHub, updates only when needed
  • Automatic Retries — up to 5 attempts with exponential backoff on failures
  • Health Check — automatic integrity verification of each repository
  • No SSH Required — uses only HTTPS with token authentication
  • Token Persistence — token is saved after first use and reused on subsequent runs
  • Progress with Error Counter — visual progress bar showing current/total/errors
  • Detailed Report — statistics on cloned/updated/synced/skipped/failed repositories
  • User Profile Export — saves GitHub user information to user_info.json
  • Branch Pruning — automatically removes local branches deleted on remote (Full Mode)
  • Organized Backups — all archives and reports stored in backups/ folder
  • Power Management — shutdown/reboot after completion (optional)
  • Fast Mode (Default) — clones only default branch for maximum speed
  • Full Mode--all-branches flag to enable synchronization of ALL branches

~/github_repos_backup_tools/              # Main application folder
└── username/                              # Your GitHub username
    ├── repositories/                       # All cloned repositories
    │   ├── repo1/                          # Repository copy
    │   ├── repo2/
    │   └── ...
    ├── backups/                            # All backup artifacts
    │   ├── backup_report_2026-02-28_15-30-45.json
    │   └── username_github_backup_2026-02-28_15-30-45.zip
    ├── config.json                          # Token file (automatically created)
    └── user_info.json                       # Your GitHub profile information

  • Python: 3.8+ (standard library only, no external dependencies)
  • Git: 2.20+
  • Storage: depends on repository sizes
  • Network: stable internet connection

1. Installation:

git clone https://github.com/smartlegionlab/github-repos-backup-tools.git
cd github-repos-backup-tools

2. First Run:

python app.py -r

On first run, the program will ask for your GitHub token and save it.

3. Get GitHub Token:

  1. Go to GitHub Tokens
  2. Select permissions: repo (full repository access), read:org (access to organization repositories)
  3. Generate and copy the token

CommandDescription
-rClone/update repositories
-tUpdate token (delete old and request new)
--no-archiveDisable archive creation (archive is created by default)
--timeout NTimeout for Git operations in seconds (default: 30)
--all-branchesEnable full branch synchronization (slower, clones ALL branches)
--shutdownShutdown computer after completion
--rebootReboot computer after completion

Usage Examples:

# Fast mode - only default branch (DEFAULT)
python app.py -r

# Full mode - ALL branches (slower but complete)
python app.py -r --all-branches

# Backup without archive
python app.py -r --no-archive

# With increased timeout
python app.py -r --timeout 60

# Update token
python app.py -t

# Backup with shutdown
python app.py -r --shutdown

Operation Modes:

ModeCommandBehaviorUse Case
Fast (Default)python app.py -rCode only, default branch after cloneQuick daily sync
Fullpython app.py -r --all-branchesFull backup with ALL branches + syncComplete backup

Status Meanings in Logs:

StatusModeMeaning
CLONEBothNew repository - full clone
PULLFastCode update (current branch only)
PULLFullCode + all branches update
SKIPFastSkipped - no changes
SYNCFullBranch sync only - code hasn't changed
CLONE (recover)FullRe-clone on error

Update Logic:

  • Quick check: compare local commit date with GitHub pushed_at
  • If difference > 5 minutes: compare actual commit hashes via ls-remote
  • If hashes differ: perform git pull
  • After pull: verify repository health with git rev-parse HEAD
  • If corrupted: automatic re-clone with retries

  • Token stored in ~/github_repos_backup_tools/[username]/config.json
  • Uses HTTPS with token in URL (not transmitted in plain text)
  • Path traversal attack protection
  • No telemetry or third-party data transmission
  • Token can be updated with -t command
  • Archives contain ONLY repositories, no tokens or configs

  • Gists not supported — utility works with repositories only
  • Git required — must be installed on the system
  • Token permissions — requires repo and read:org

Q: Authentication fails?
Verify token has repo and read:org permissions. Use -t to update.
Q: Clone timeout?
Increase timeout: --timeout 60
Q: Where is token stored?
In ~/github_repos_backup_tools/[username]/config.json
Q: Where are backups stored?
All archives and reports are in ~/github_repos_backup_tools/[username]/backups/
Q: What's in user_info.json?
Your GitHub profile information - login, name, email, repo counts, followers, etc.
Q: How to cancel scheduled shutdown?
shutdown -c (Linux/macOS) or shutdown /a (Windows)

  • User profile export — saves GitHub user info to user_info.json
  • Organized backups — all archives and reports in backups/ folder
  • Cleaner archives — ZIP contains only repositories, no configs or tokens
  • Improved structure~/github_repos_backup_tools/[username]/backups/
  • Branch pruning — automatically removes local branches deleted on remote
  • No SSH required — uses only HTTPS with token authentication
  • Smart update — two-stage verification (date + hash) before pull
  • Health checks — verifies repository integrity after each operation
  • Automatic recovery — re-clones corrupted repositories
  • Exponential backoff — up to 5 retries with increasing delays
  • Two operation modes — Fast (default) and Full (--all-branches)

********************************************************************************
----------------------- GitHub Repositories Backup Tools -----------------------

🔧 Arguments Parsing:
   Backup: Repositories, Archive
   Timeout: 30s
   Branches: ⚡ Fast mode (default branch only)
   Power: ❌ No action

🔐 GitHub Authentication
   Found existing user: smartlegionlab
✅ Authenticated as: smartlegionlab

🔍 Scanning repositories...
   ✅ Found 52 repositories

📁 Backup location: /home/user/github_repos_backup_tools/smartlegionlab

[██████████████████████████████] 100.0% | 52/52/0 | SKIP | smartlegionlab/repo
✅ Repository processing complete!

============================================================
📋 BACKUP REPORT
============================================================
👤 User: smartlegionlab
⏱️  Duration: 0:05:18

📊 REPOSITORY STATISTICS:
   Total:           52 repositories
   ⏭️ Skipped:        52 repositories (no changes)
   ❌ Failed:          0 repositories

✅ Success rate: 100.0%
============================================================

📦 Archive created: smartlegionlab_github_backup_2026-02-27_17-24-20.zip
   📊 Size: 15.19 MB
------------------------------------------------------------------------------------
----------------------- Copyright © 2026, Alexander Suvorov ------------------------
************************************************************************************

By using this software, you agree to the full disclaimer terms.

Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md

License: BSD 3-Clause License