Metadata-Version: 2.4
Name: gs-git-backup
Version: 1.0.0
Summary: GitHub backup and restore CLI tool with issues, PRs, and full repository history
Author-email: Harsh Yadav <HarshYadav152@outlook.com>
License: MIT
Keywords: github,backup,restore,cli,issues,pull requests
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENCE
Requires-Dist: requests>=2.28.0
Requires-Dist: PyGithub>=1.59
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: license-file

# 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):**

```bash
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:

```bash
gs-git-backup login
```

Output:

```text
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:

```text
✅ Using existing credentials at: /home/username/.gs_git_backup/config.json
```

---

## 💾 Backup Repositories

### Backup all repositories:

```bash
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:

```bash
gs-git-backup gsbackup repo1 repo2
```

* Only backs up `repo1` and `repo2`.

### Force re-login during backup:

```bash
gs-git-backup gsbackup --login
```

* Prompts for GitHub credentials again and updates the config file.

---

## 🔄 Restore Repositories

### Restore all repositories from a backup folder:

```bash
gs-git-backup gsrestore github_backup/
```

* Restores all `.git` repos in the backup folder to `restored_repos/`.

### Restore with a custom output directory:

```bash
gs-git-backup gsrestore github_backup/ --output my_projects
```

* All repositories will be restored in `my_projects/`.

### Restore a single repo:

```bash
gs-git-backup gsrestore github_backup/repo1/repo.git
```

* Restores only `repo1`.

---

## 📁 Project Structure

```text
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](LICENSE) file for details.
