https://github.com/simenandre/backup-repos
https://github.com/simenandre/backup-repos
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/simenandre/backup-repos
- Owner: simenandre
- Created: 2026-03-21T20:14:09.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-03-21T21:19:03.000Z (3 months ago)
- Last Synced: 2026-04-06T12:31:02.472Z (3 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# backup-repos
Back up all GitHub repositories for a user or organization to a Hetzner storage box.
Clones repos as bare git repositories, then rsyncs them over SSH. Supports incremental backups (fetches only new changes on subsequent runs).
## Configuration
All configuration is via environment variables:
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `GITHUB_TOKEN` | Yes | — | GitHub PAT with repo read scope |
| `GITHUB_OWNER` | Yes | — | GitHub user or org name |
| `GITHUB_OWNER_TYPE` | No | `org` | `user` or `org` |
| `STORAGE_BOX_HOST` | Yes | — | e.g. `uXXXXXX.your-storagebox.de` |
| `STORAGE_BOX_USER` | Yes | — | SSH username |
| `STORAGE_BOX_PORT` | No | `23` | SSH port (Hetzner default is 23) |
| `STORAGE_BOX_PATH` | No | `./backups` | Remote base path |
| `WORK_DIR` | No | `/tmp/backup-repos` | Local staging directory |
## Usage
### Run locally
```sh
export GITHUB_TOKEN=ghp_...
export GITHUB_OWNER=myorg
export STORAGE_BOX_HOST=uXXXXXX.your-storagebox.de
export STORAGE_BOX_USER=uXXXXXX
go run ./cmd/backup-repos
```
### GitHub Actions
The included workflow (`.github/workflows/backup.yml`) runs daily at 03:00 UTC. Configure these secrets in your repository settings:
- `BACKUP_GITHUB_TOKEN` — GitHub PAT (not the built-in `GITHUB_TOKEN`)
- `GITHUB_OWNER`
- `GITHUB_OWNER_TYPE`
- `STORAGE_BOX_HOST`
- `STORAGE_BOX_USER`
- `STORAGE_BOX_SSH_KEY` — Private SSH key for the storage box
- `STORAGE_BOX_PATH`
You can also trigger the workflow manually via the Actions tab.