Skip to main content

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

Project description

gh-backup

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

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
--gc Run git gc --aggressive on each clone to shrink pack files
--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)

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

gh_backup-0.2.0.tar.gz (69.3 kB view details)

Uploaded Source

Built Distribution

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

gh_backup-0.2.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file gh_backup-0.2.0.tar.gz.

File metadata

  • Download URL: gh_backup-0.2.0.tar.gz
  • Upload date:
  • Size: 69.3 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for gh_backup-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e7a722a8b8f0dc9d7848b0f7956add47d3c41d9091e331b1db1fbac092ef89f8
MD5 7e810d5ba2af373fc81c79818590efcf
BLAKE2b-256 4d969e1067c4c0ab931cfc4fea0f6a9066576dfe565611f37ae5405318e5e2ab

See more details on using hashes here.

File details

Details for the file gh_backup-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gh_backup-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for gh_backup-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e78dabfb40ae6674578086b4450bdc9a9bb046bbdad92e250c87a6de47684ad
MD5 7d7cbdc5c75ede10945a32151430e73b
BLAKE2b-256 ef6e33036efdecdd528b0dc52119080bfda8243cc2a9e542a399d1bd46541ef7

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