Skip to main content

GitHub backup and restore CLI tool with issues, PRs, and full repository history

Project description

gs-git-backup

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.


⚡ Features

  • 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 gs for easy usage.

🏗️ Installation

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-backup in your Python environment.
  • Make sure Python >= 3.8 is installed.

🔐 Config / Login

The first time you use the tool, it will ask for your GitHub credentials:

gs-git-backup login

Output:

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

💾 Backup Repositories

Backup all repositories:

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.json
    • pulls.json
    • releases.json
    • contributors.json
  • Creates a zipped file for each repo: repo-name.zip

Backup specific repositories:

gs-git-backup gsbackup repo1 repo2
  • Only backs up repo1 and repo2.

Force re-login during backup:

gs-git-backup gsbackup --login
  • Prompts for GitHub credentials again and updates the config file.

🔄 Restore Repositories

Restore all repositories from a backup folder:

gs-git-backup gsrestore github_backup/
  • Restores all .git repos in the backup folder to restored_repos/.

Restore with a custom output directory:

gs-git-backup gsrestore github_backup/ --output my_projects
  • All repositories will be restored in my_projects/.

Restore a single repo:

gs-git-backup gsrestore github_backup/repo1/repo.git
  • Restores only repo1.

📁 Project Structure

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 package
  • cli.py → CLI entry point (gs-git-backup)
  • pyproject.toml → PyPI / pip build info

🔧 CLI Commands Summary

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

⚙️ Requirements

  • Python >= 3.8
  • pip
  • requests Python library
  • Git installed (git must be in PATH)

📝 Contribution

  • Fork the repo, make changes, and submit a PR.
  • Please make sure gs-git-backup command works after any changes.
  • Follow PEP8 style for Python code.

📄 License

MIT License – see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gs_git_backup-1.0.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gs_git_backup-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file gs_git_backup-1.0.0.tar.gz.

File metadata

  • Download URL: gs_git_backup-1.0.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for gs_git_backup-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8f3ca6d25b442a809d014bd3f27ce7b42651fdde969d2ece8ce9f928f3b560de
MD5 f6525e4a7cabdb48f8908714ed3c04ed
BLAKE2b-256 fc1337c16513e8a8222d4ef67c7d673375cf7bff59760f5e1ef15c2284f6a598

See more details on using hashes here.

File details

Details for the file gs_git_backup-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gs_git_backup-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for gs_git_backup-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cdcda1ab6d1f51eee9e12056ae0c63636b848afeec78424a0ac168405706d2b
MD5 908570c2e29dd252e80d82b6190efe38
BLAKE2b-256 5a3b9b827eac9a2fea1fe2805a6a497d525d83240e71ee68a0378c9a7acef53d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page