A tool built with Spring Boot to backup public GitHub repositories for specified users or organizations. Available as both a command-line tool and a web application.
- Web UI for easy backup management through your browser
- Daemon Mode with Docker support for automatic daily backups
- Backup all public repositories from one or more GitHub users/organizations
- Clone new repositories or update existing ones
- Interactive mode for easier management and status viewing
- Support for authenticated and anonymous GitHub API access
- Parallel backup of multiple users/organizations
- Organized backup structure by user/organization
- Java 17 or higher
- Maven 3.6+ (for building from source)
- Git (for cloning repositories)
git clone https://github.com/dmccoystephenson/gh-backup.git
cd gh-backup
mvn clean packageThe executable JAR will be created at target/gh-backup-1.0.0.jar
The easiest way to run automatic daily backups is using Docker. This will spin up a background service that backs up your configured repositories every 24 hours.
- Create a
.envfile (or copy from.env.example):
cp .env.example .env- Edit
.envto configure your backups:
GITHUB_TOKEN=your_github_token_here
SCHEDULED_USERS=octocat,github,spring-projects- Start the daemon service:
docker-compose up -dThe service will:
- Run the first backup immediately
- Continue running in the background
- Automatically backup every 24 hours
- Persist backups to the
./backupsdirectory on your host machine
- View logs:
docker-compose logs -f- Stop the service:
docker-compose downBuild the image:
docker build -t gh-backup .Run the daemon:
docker run -d \
-e GITHUB_TOKEN=your_token \
-e SCHEDULED_USERS=octocat,github \
-v $(pwd)/backups:/backups \
--name gh-backup-daemon \
gh-backupYou can also run daemon mode directly with Java:
java -Dspring.profiles.active=daemon \
-Dbackup.scheduled.users=octocat,github \
-Dbackup.directory=/path/to/backups \
-jar target/gh-backup-1.0.0.jarStart the web server:
java -Dspring.profiles.active=web -jar target/gh-backup-1.0.0.jarThen open your browser and navigate to http://localhost:8080 to access the web interface.
The web UI allows you to:
- Create new backups by entering a GitHub user or organization name
- View the status of all your backups
- See a list of all backed up repositories with their last update times
To use a custom port:
java -Dspring.profiles.active=web -Dserver.port=9000 -jar target/gh-backup-1.0.0.jarStart the tool in interactive mode for easier management:
java -jar target/gh-backup-1.0.0.jar -iIn interactive mode, you can:
- Type
backup <user/org>to backup a user or organization's repositories - Type
statusto view current backup status and list all backed up repositories - Type
exitto quit
Example session:
> backup octocat
Fetching repositories for: octocat
Found 8 public repositories
...
> status
Backup Status
=============
Backup directory: /path/to/backups
octocat/ (8 repositories)
- Hello-World (last updated: 2026-01-10 12:30:45)
- Spoon-Knife (last updated: 2026-01-10 12:30:47)
...
Total: 1 users/organizations, 8 repositories
> exit
Exiting interactive mode...
Backup repositories for one or more users/organizations:
java -jar target/gh-backup-1.0.0.jar <user/org1> [user/org2] ...Backup repositories from a single user:
java -jar target/gh-backup-1.0.0.jar octocatBackup repositories from multiple users/organizations:
java -jar target/gh-backup-1.0.0.jar octocat github spring-projectsFor higher rate limits and access to more API features, set the GITHUB_TOKEN environment variable:
export GITHUB_TOKEN=your_github_token_here
java -jar target/gh-backup-1.0.0.jar octocatTo create a GitHub personal access token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Click "Generate new token"
- Select scopes (public_repo is sufficient for public repositories)
- Copy the generated token
By default, repositories are backed up to ~/gh-backups/ (user home directory). This works on both Linux and Windows. To use a custom location:
java -Dbackup.directory=/path/to/backup -jar target/gh-backup-1.0.0.jar octocatWindows example:
java -Dbackup.directory=C:\Backups\GitHub -jar target/gh-backup-1.0.0.jar octocatThe backup directory path is automatically converted to an absolute path and normalized for cross-platform compatibility.
Repositories are organized by user/organization in the backup directory:
~/gh-backups/
├── octocat/
│ ├── Hello-World/
│ ├── Spoon-Knife/
│ └── ...
├── github/
│ ├── docs/
│ ├── roadmap/
│ └── ...
└── ...
- The tool connects to the GitHub API (authenticated or anonymously)
- For each specified user/organization, it fetches all public repositories
- Each repository is cloned to the local backup directory
- If a repository already exists, it is updated with
git fetch
- Anonymous: 60 requests per hour
- Authenticated: 5,000 requests per hour
Using authentication is recommended for backing up users/organizations with many repositories.
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.