Skip to content

GeetaSystems/gs-git-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages