gs-git-backup is a command-line tool to backup and restore GitHub repositories, including code, issues, pull requests, releases, and contributors. It supports backing up all repos or specific repos and stores your GitHub credentials securely in a local config file.
- Backup all repositories of a GitHub user.
- Backup specific repositories by name.
- Backup issues, pull requests, releases, and contributors as JSON.
- Full repository clone (
--mirror) included. - Restore repositories from backup.
- Persistent GitHub credentials in
~/.gs_git_backup/config.json. - CLI commands prefixed with
gsfor easy usage.
Install via pip (editable for development):
git clone https://github.com/GeetaSystems/gs-git-backup.git
cd gs-git-backup
pip install -e .- This will register the command
gs-git-backupin your Python environment. - Make sure Python >= 3.8 is installed.
The first time you use the tool, it will ask for your GitHub credentials:
gs-git-backup loginOutput:
Enter GitHub username: johndoe
Enter GitHub token (hidden):
✅ Credentials saved at: /home/username/.gs_git_backup/config.json
- The credentials are stored in plain JSON at
~/.gs_git_backup/config.json. - If credentials already exist, it will automatically use them:
✅ Using existing credentials at: /home/username/.gs_git_backup/config.json
gs-git-backup gsbackup-
Backs up all repositories.
-
Creates
github_backup/folder in the current directory. -
Each repo folder contains:
repo.git/(full mirror)issues.jsonpulls.jsonreleases.jsoncontributors.json
-
Creates a zipped file for each repo:
repo-name.zip
gs-git-backup gsbackup repo1 repo2- Only backs up
repo1andrepo2.
gs-git-backup gsbackup --login- Prompts for GitHub credentials again and updates the config file.
gs-git-backup gsrestore github_backup/- Restores all
.gitrepos in the backup folder torestored_repos/.
gs-git-backup gsrestore github_backup/ --output my_projects- All repositories will be restored in
my_projects/.
gs-git-backup gsrestore github_backup/repo1/repo.git- Restores only
repo1.
gs-git-backup/
├── gs_git_backup/
│ ├── __init__.py
│ ├── gsbackup.py # Backup logic
│ ├── gsrestore.py # Restore logic
│ └── config.py # GitHub credentials handling
├── cli.py # Entry point for CLI command
├── pyproject.toml
└── README.md
gs_git_backup/→ Python packagecli.py→ CLI entry point (gs-git-backup)pyproject.toml→ PyPI / pip build info
| Command | Description |
|---|---|
gs-git-backup login |
Save or update GitHub credentials |
gs-git-backup gsbackup |
Backup all repos |
gs-git-backup gsbackup <repo1> <repo2> |
Backup specific repos |
gs-git-backup gsbackup --login |
Force re-login during backup |
gs-git-backup gsrestore <backup_folder> |
Restore all repos from backup folder |
gs-git-backup gsrestore <backup_folder> --output <folder> |
Restore to custom folder |
gs-git-backup gsrestore <repo.git> |
Restore a single repo |
- Python >= 3.8
- pip
requestsPython library- Git installed (
gitmust be in PATH)
- Fork the repo, make changes, and submit a PR.
- Please make sure
gs-git-backupcommand works after any changes. - Follow PEP8 style for Python code.
MIT License – see LICENSE file for details.