Skip to content
Stephenson-SoftwarePublic

About

Backup public GitHub repositories for specified users or organizations.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

gh-backup

gh-backup interactive mode backing up the octocat demo account, then showing its status

A real interactive session backing up GitHub's public octocat demo account (8 repositories).

The status command after the backup: 8 octocat repositories with their last-updated times

The status command after that backup.

Description

gh-backup is a Spring Boot tool for backing up public GitHub repositories for specified users or organizations. It is available as a command-line tool, a web application, and a daemon that runs scheduled backups automatically (with Docker support).

Installation

First Time Installation

  1. Ensure Java 17+ and Maven 3.6+ are installed.
  2. Clone the repository:
    git clone https://github.com/Stephenson-Software/gh-backup.git
    cd gh-backup
  3. Build the project:
    mvn clean package
  4. The executable JAR will be created at target/gh-backup-2.0.0-SNAPSHOT-8-8-2026.jar.

Usage

Documentation

Support

You can find the support Discord server here.

Experiencing a bug?

Please fill out a bug report here.

Usage reporting

Usage reporting is on by default: gh-backup reports that it was used to the maintainers' trace service at https://trace.danielstephenson.dev, sending a startup event once per process and a backup-completed event when a backup run finishes, each carrying its name and version. Apart from the installation ID described below, nothing else is sent: nothing about the users, organizations or repositories being backed up, and no usernames, hostnames, IP addresses, paths or command-line arguments. A one-line notice is logged the first time it runs on a machine (recorded in ~/.config/gh-backup/usage-reporting-notice-shown), or on every run when there is no usable home directory to record it in.

Every event also carries a random installation ID (the tag install), so installations can be counted rather than events. It is the value of TRACE_INSTALL_ID when that is set, and otherwise a random UUID written the first time reporting runs to ~/.config/gh-backup/trace-install-id, next to the notice marker, and reused after that (in the Docker image that directory is inside the container, so a recreated container counts as a new installation unless TRACE_INSTALL_ID is set). It identifies no person, account, host or address. Delete the file to get a new one. Every opt-out below also stops it: when reporting is off, no ID is made up and the file is neither read nor written.

To turn it off, any one of these is enough:

  • java -Dusage.reporting.enabled=false -jar ... (or usage.reporting.enabled=false in an application.properties next to the JAR)
  • USAGE_REPORTING_ENABLED=false in the environment (.env for the Docker daemon)
  • TRACE_USAGE_REPORTING=off (also false, 0, no) in the environment — the switch every trace client honours, checked before gh-backup's own setting
  • DO_NOT_TRACK=1 (also true, yes) in the environment, per consoledonottrack.com

Every switch fails closed, so an opt-out is never read as "on": usage.reporting.enabled / USAGE_REPORTING_ENABLED keeps reporting on only for true, on, yes or 1 (any case) and turns it off for anything else, blank or a typo included; TRACE_USAGE_REPORTING set to anything but blank or one of those values turns it off; DO_NOT_TRACK set to anything but blank, 0, false, off or no turns it off.

See usage.reporting.enabled in the Configuration Guide, and for what trace collects and why: https://danielstephenson.dev/usage-reporting

Contributing

Testing

Unit Tests

Linux / macOS:

mvn clean test

Windows:

mvn clean test

If you see BUILD SUCCESS, the tests have passed.

Entrypoint Script Test

docker-entrypoint.sh is covered by a shell test that runs it against a stub java and asserts the arguments it builds. A POSIX shell is required, so on Windows it is run under WSL or Git Bash.

Linux / macOS:

sh docker-entrypoint-test.sh

Windows (Git Bash / WSL):

sh docker-entrypoint-test.sh

If you see All docker-entrypoint.sh tests passed., the tests have passed.

Development

Building and Running Locally

  1. Clone the repository and build:
    mvn clean package
  2. Run in CLI mode:
    java -jar target/gh-backup-2.0.0-SNAPSHOT-8-8-2026.jar octocat
  3. Run in web mode:
    java -Dspring.profiles.active=web -jar target/gh-backup-2.0.0-SNAPSHOT-8-8-2026.jar
    Then open http://localhost:8080 in your browser.
  4. Run in daemon mode (automatic scheduled backups):
    java -Dspring.profiles.active=daemon -Dbackup.scheduled.users=octocat,github -jar target/gh-backup-2.0.0-SNAPSHOT-8-8-2026.jar
    See Docker Deployment below for a containerized setup, and COMMANDS.md for all daemon options.

Docker Deployment (Daemon Mode)

The repository includes a Dockerfile and docker-compose.yml for running gh-backup as a background service that backs up configured users/organizations every 24 hours by default.

  1. Create a .env file from the example and configure it:
    cp .env.example .env
  2. Start the daemon:
    docker-compose up -d
  3. View logs:
    docker-compose logs -f
  4. Stop the daemon:
    docker-compose down

See CONFIG.md for the full list of daemon configuration options.

Authors and Acknowledgement

Developers

Name Main Contributions
dmccoystephenson Initial development and maintenance

How the screenshots were captured

docs/images/gh-backup-interactive.gif and docs/images/gh-backup-status.png were recorded on 2026-10-18 from a real run of the JAR built with mvn package, started with the exact command shown in the GIF, against GitHub's public octocat demo account. No GitHub token was set, so only public repositories could be listed, and TRACE_USAGE_REPORTING=off was set so that no usage reports were sent. The commands were typed into a pseudo-terminal by a script, and the recorded terminal output was rendered to an image with pyte and Pillow. Nothing in the output was edited; only the window frame was added. Pauses longer than 1.5 seconds were shortened in the GIF, and the PNG is the last 17 lines of the same run.

License

This project is licensed under the MIT License.

You are free to use, modify, and distribute this software under the terms of the MIT License.

See the LICENSE file for the full license text.

Project Status

This project is in active development.

Changelog

See CHANGELOG.md for a release-by-release summary of changes.

About

Backup public GitHub repositories for specified users or organizations.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages