piotrpress / github-backup
CLI tool for bulk downloading GitHub repositories as ZIP archives.
Requires
- php: >=8.5
- piotrpress/typed-collection: ^1.0
- symfony/console: ^8.1
- symfony/filesystem: ^8.1
- symfony/http-client: ^8.1
- symfony/lock: ^8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-30 22:19:56 UTC
README
CLI tool for bulk downloading GitHub repositories as ZIP archives.
Usage
php gb <directory> [-o|--owner OWNER] [-p|--pattern PATTERN]
or via Docker:
./bin/run <directory> [-o|--owner OWNER] [-p|--pattern PATTERN]
Arguments
directory- Directory where the repositories will be backed up. If the directory does not exist, it will be created.
Options
-o|--owner OWNER- GitHub owner (user or organization) of the repositories to backup. If not specified, backup will be performed for all repositories of the authenticated user.-p|--pattern PATTERN- Pattern to filter repositories by name. If not specified, all repositories will be backed up.
Description
GithubBackup is a PHP command-line application that downloads GitHub repositories
as ZIP archives. It lists repositories accessible to the authenticated user,
optionally filters them by owner and repository name, and saves each archive
under <directory>/<owner>/<repository>/ with a UTC timestamp in its filename.
Downloads are streamed to disk and incomplete archives are removed if a download fails. Each run creates a new archive, making the tool suitable for periodic execution with an external scheduler such as cron.
ZIP archives contain a snapshot of the repository's default branch, not its Git history, other branches, or tags.
Development
./bin/dev
Requirements
- PHP
8.5or higher - Composer
2.5or higher - GitHub Token with
reposcope. Set it as an environment variable:
export GITHUB_TOKEN=<your_token>
or for Docker:
- Docker
24.0or higher. Run the container with the token in.envfile:
GITHUB_TOKEN=<your_token>