An open API service indexing awesome lists of open source software.

https://github.com/dostuffthatmatters/github-export-tool

downloads everything from a list of GitHub organizations and users
https://github.com/dostuffthatmatters/github-export-tool

backup download export git github github-cli periodic

Last synced: 6 months ago
JSON representation

downloads everything from a list of GitHub organizations and users

Awesome Lists containing this project

README

          

# 💾  Github Export Tool

A tool that downloads everything from a list of GitHub organizations and users.

- [x] ⚙️  Code (with all branches and tags)
- [ ] 🪲  Issues
- [ ] ⚔️  Pull Requests
- [ ] 📍  Releases
- [ ] 🚛  LFS items

This can be used to periodically back up your whole organization. Existing tools that do this backup are crazy expensive (like https://rewind.com/pricing-backups/). And export via migration is only available for GitHub Enterprise.

Under the hood, this tool uses the [GitHub CLI](https://cli.github.com/). Currently only works when using authentication via SSH.

**🙌 Contributions are welcome.**


## ⚔️ How to Use it?

1. Install Poetry (https://python-poetry.org/)
2. Install Python3.10 (https://python.org/)
3. Install the GitHub CLI (https://cli.github.com/)
4. Authenticate your GitHub CLI

```bash
gh auth
```

5. Create venv and install dependencies:

```bash
python3.10 -m venv .venv
source .venv/bin/activate
poetry install
```

6. Use the `config.template.json` to create a `config.json`
7. Run

```bash
python run.py
```


## 🥷 Some Details

- For each organization/username, it calls `gh repo list --json name --limit 1000` to get the respective repository names.
- It clones the repo with all branches using `git clone git@github.com:/.git --mirror`.
- It only downloads the repositories that have been updated since the last run. Using the `gh repo view / --json pushedAt` command for every repo, it fetches the last commit time on any branch and saves it to `out/github-meta.json`.
- You can configure the command used to call the GitHub CLI. Since the abbreviation `gh` is very short you could just set the actual path - e.g. `config.github_cli = "/opt/homebrew/bin/gh"`.