Skip to main content

gh-backup

CI codecov PyPI Python 3.13+ License: AGPL-3.0 Ruff uv pre-commit Conventional Commits

Backup a GitHub organization or user: repos, issues, and pull requests.

Clones all repositories with full git history and exports issues/PRs as JSON, then compresses everything into a .tar.zst archive.

Requirements

  • GitHub CLI (gh) — authenticated with a token that has repo and read:org scopes

Installation

# uv (recommended)
uv tool install gh-backup

# pip
pip install gh-backup

# pipx
pipx install gh-backup

Authentication

gh-backup auth

Checks that gh is authenticated and reports the active account and token scopes.

Usage

Export an organization

gh-backup export myorg --output /backups

Export a user account

gh-backup export myusername --output /backups

Account type (org or user) is detected automatically.

Options

Option Short Description
--output PATH -o Directory to write exports into (required)
--workers N -w Parallel clone workers (default: 4, max: 32)
--repos NAME -r Only export specific repos (repeatable)
--format Archive format: zst (default), gz, or xz
--no-compress Keep raw export directory, skip archiving
--keep-dir Keep uncompressed directory after archiving
--shallow Shallow clone (--depth 1); faster but no full history
--gc Run git gc --aggressive on each clone to shrink pack files
--dry-run List repos that would be exported without writing anything
--skip-forks Exclude forked repositories
--skip-archived Exclude archived repositories
--visibility Only export repos with this visibility: all (default), public, or private
--skip-issues Skip issues and pull request export
--verbose -v Enable debug logging

Examples

# Export an org with more workers
gh-backup export myorg --output /backups --workers 8

# Export specific repos only
gh-backup export myorg --output /backups --repos frontend --repos backend

# Export a user account, skip issues, no compression
gh-backup export myusername --output /backups --skip-issues --no-compress

# Export with GZ compression instead of ZST
gh-backup export myorg --output /backups --format gz

Each run is saved to a timestamped subdirectory under the output directory, then compressed into a single archive.

Output structure

The archive unpacks to:

<org>-<timestamp>/
├── metadata.json       # Export config and repo stats
├── repos/
│   ├── repo1.git       # Bare mirror clone (git clone --mirror)
│   └── ...
└── issues/
    ├── repo1/
    │   ├── issues.json
    │   └── pulls.json
    └── ...

Exit codes

Code Meaning
0 Success
1 Export failed
2 Partial failure — some repos failed, others succeeded
130 Cancelled with Ctrl+C

Development

Requires uv.

make install    # Install dependencies and set up pre-commit hooks
make test       # Run the test suite
make lint       # Check linting and formatting (ruff)
make lint-fix   # Auto-fix linting and formatting issues
make commit     # Create a conventional commit (via commitizen)

Metadata

Release files for gh-backup 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gh-backup 0.3.0
File Size Uploaded Provenance Actions
gh_backup-0.3.0.tar.gz 80.2 kB Without provenance Details for gh_backup-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gh-backup 0.3.0
File Interpreter ABI Platform Actions
gh_backup-0.3.0-py3-none-any.whl Python 3 none any Details for gh_backup-0.3.0-py3-none-any.whl

Total release size: 108.5 kB

Release files / gh_backup-0.3.0.tar.gz

Download URL gh_backup-0.3.0.tar.gz
Size 80.2 kB
Tags Source
SHA-256 checksum
How to use checksums
814a38d0bb6301e3b5799120dd700dd3783977cc06aca92592e6d644a7ff9a1f
BLAKE2b-256 checksum
How to use checksums
d550b18c05d3562ecaaf24fe83c7f345016cdaba4c45db70e0f75c7405bd8f2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gh_backup-0.3.0-py3-none-any.whl

Download URL gh_backup-0.3.0-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4597e2e18b2b8da9a167274cd3dab0ebb4f6bd1c96a8b2b58be7c203325110c5
BLAKE2b-256 checksum
How to use checksums
99de2404aae943a13e337feabfcad98f7c8b990924bc09a035a1d0cf47b81cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for gh-backup 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page