Skip to main content

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

Project description

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)

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.3.0.tar.gz (80.2 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.3.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gh_backup-0.3.0.tar.gz
  • Upload date:
  • Size: 80.2 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.3.0.tar.gz
Algorithm Hash digest
SHA256 814a38d0bb6301e3b5799120dd700dd3783977cc06aca92592e6d644a7ff9a1f
MD5 8547c61d0f5342df65d8fb99ea1b52d2
BLAKE2b-256 d550b18c05d3562ecaaf24fe83c7f345016cdaba4c45db70e0f75c7405bd8f2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gh_backup-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4597e2e18b2b8da9a167274cd3dab0ebb4f6bd1c96a8b2b58be7c203325110c5
MD5 74de2452ba6e6bd3965e6ac075437abf
BLAKE2b-256 99de2404aae943a13e337feabfcad98f7c8b990924bc09a035a1d0cf47b81cbd

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